题目描述
Problem Description
Iroha-chan has \(N\\) roulette disks and a sufficient number of roulette balls. Each disk is assigned an integer number from \(1\\) to \(N\\).
The circumference of each disk is marked with integers. Specifically, disk \(i\\) has \(M\_i\\) integers \(A\_{i,1},\\ A\_{i,2},\\ \\dots\\ A\_{i,M\_i}\\) written on it. These integers may have duplicates.
When disk \(i\\) is spun and a ball is rolled onto it, the ball will land in one of the spots marked with \(A\_{i,1},\\ A\_{i,2},\\ \\dots\\ A\_{i,M\_i}\\). The probability of the ball landing in \(A\_{i, j}\\ (1≦j≦M\_i)\\) is \(1/{M\_i}\\).
One day, Iroha-chan, with her genius idea, thought of a game using these disks. It goes as follows:
- First, spin all the disks and roll a ball onto each.
- Read the integers written where the balls landed, in the order of disks \(1, 2, \\dots N\\).
- For example, if there are \(3\\) disks and the integers where the balls landed on disks \(1, 2, 3\\) are \(11, 2, 717\\) respectively, then \(112717\\) is read.
Iroha-chan wants to know the expected value of the integer that can be read. However, since she is not a programmer, she cannot calculate the expected value.
I don't know if you are an excellent programmer, but please calculate the expected value for Iroha-chan, who is not a programmer.
Since the expected value (hereafter referred to as \(E\\)) may be a decimal, instead find \(E \\times M\_1 \\times M\_2 \\times\\ \\dots\\times\\ M\_N\\) (this value is always an integer) modulo \(10^9+7\\).
Input Format
The input is given in the following format:
```
\(N\)
\(M_1\ A_{1, 1}\ A_{1, 2}\ \dots\ A_{1, M_1}\)
\(M_2\ A_{2, 1}\ A_{2, 2}\ \dots\ A_{2, M_2}\)
\(\vdots\)
\(M_N\ A_{N, 1}\ A_{N, 2}\ \dots\ A_{N, M_N}\)
## Output Format
Output \\(E \\times M\_1 \\times M\_2 \\times\\ \\dots\\times\\ M\_N\\) modulo \\(10^9+7\\).
## Sample Input and Output
### Sample Input #1
2
2 11 3
2 9 14
### Sample Output #1
1586
### Sample Input #2
3
3 172 11 31
2 701 5
2 12 21
### Sample Output #2
43651798
### Sample Input #3
3
1 1000000000
1 1000000000
1 1000000000
### Sample Output #3
999966190
### Sample Input #4
10
5 371094 2597554 69382646 8 99062422
12 6553139 40789 2519037 81594 46824888 84 4912 27575435 2774 4060 331605 7438162
5 36 65156096 71969458 2 221919
7 738734 979629710 4841 7027881 6107446 267092962 634173170
9 16252 6294622 6670 932636725 8 221842 111612 86053044 823517544
3 589 70 347090831
9 7853 6 3174 1 14675 42 10793760 777031 23350
15 5143 23971 93 68615 4384503 3 5867 96099 81021 10506439 137503 43398308 52626 9895727 3
6 9819 93 808 2025523 36 593697
3 497384 767669 80690
### Sample Output #4
993753975
```
Notes/Hints
Constraints
- All inputs are integers.
- \(1≦N≦200,000\\)
- \(1≦M\_i\\ (1≦i≦N)\\)
- \(M\_1 + M\_2 +\\ \\dots\\ + M\_N≦200,000\\)
- \(1≦A\_{i, j}≦10^9\\ (1≦i≦N, 1≦j≦M\_i)\\)
Sample Explanation 1
In this input example, there are \(2\\) disks with \(11, 3\\) and \(9, 14\\) written on them, respectively. The possible integers that can be read are \(119, 1114, 39, 314\\), each with equal probability, so the expected value is \(\\frac{119+1114+39+314}{4}=396.5\\). The answer is \(396.5 \\times 2 \\times 2 = 1586\\).
Sample Explanation 2
The possible integers that can be read are \(11512, 11521, 31512, 31521, 172512, 172521, 1170112, 1170121, 3170112, 3170121, 17270112, 17270121\\).
Sample Explanation 3
In this input example, \(100000000010000000001000000000\\) is always read. Note to find the remainder when divided by \(10^9+7\\).
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分