TimeLimit: 2000/1000 MS (Java/Others) MemoryLimit: 65536/65536 K (Java/Others)
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Rhason Cheung had a simple problem, and asked Teacher Mai for help. But Teacher Mai thought this problem was too simple, sometimes naive. So she ask you for help.
Teacher Mai has functions (that means for all ). But Rhason only knows some of these functions, and others are unknown.
She wants to know how many different function series there are that for every ,. Two function series and are considered different if and only if there exist ,.
Input
For each test case, the first lines contains two numbers n,m(1≤n,m≤100).
The following are m lines. In i-th line, there is one number −1 or n space-separated numbers.
If there is only one number −1, the function fi is unknown. Otherwise the j-th number in the i-th line means fi(j).
Output
For each test case print the answer modulo 10^9+7.
SampleInput
3 3
1 2 3
-1
3 2 1
SampleOutput
1
Hint
The order in the function series is determined. What she can do is to assign the values to the unknown functions.