The translation of riichi terms comes from WRC and EMA
Kujo Karen loves playing Majsoul, so she makes out a problem about Majsoul. Wish you won't no longer love Majsoul because of this problem.
Today Karen decides to play Majsoul, but all her friends have gone to play Dota AutoChess and Karen have to play Majsoul alone. She finds a special mahjong set. The mahjong set consists of ranks of tiles (ranked from to ), and each rank of tiles include 4 tiles (numbered from 1 to 4). In this problem, we DO NOT consider their suits.
A chow (shuntsu 順子) is three consecutive tiles (i.e. their ranks are , , respectively). A pung (kōtsu 刻子) is composed of three identical tiles. A group (mentsu 面子) is either a chow or pung (In this problem, we DO NOT consider kong). A pair (toitsu 対子) is composed of two identical tiles.
A player's hand (his/her 14 tiles) is a winning hand if it has four groups and a pair, or seven different pairs.
For example, these hands are winning hands:
And these are not:
Firstly, Karen draws tiles from the wall, and shuffle the remaining tiles. The shuffle is at random, i.e. all the permutations have equal probability to appear.
For a permutation , denote as a mahjong hand composed of Karen's prepared tiles and 's first tiles. the weight of is the smallest which can let exist a subset that is a winning hand. If you are familiar with mahjong, obviously the weight of equals to the minimum turns to complete a winning hand. Notice that when , always has a subset that is a winning hand, so the weight of is well-defined.
She lets you to calculate the expected value of the weight of in advance.
接下来输入 行每行两个整数 ，表示可怜最开始摸出的第 张牌是大小为 的第 张牌，保证 二元组两两不同。In the following lines, each line includes 2 integers , represents that the -th tile Karen draws is the -th tile of rank .