# #3042. 「ZJOI2019」麻将

#### 题目描述

• 可以被划分成五个集合 。其中 为对子， 为面子。
• 可以被划分成七个集合 ，它们都是对子，且对应的大小两两不同

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.

#### 样例输入

9
1 1
1 2
1 3
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
9 2
9 3


#### 样例输出

1


#### 样例说明

It forms pure nine gates. Obviously, no matter what card is added, it would complete a winning hand. Therefore, for every , its weight is , and that's why the expected value of the weight of is .