There are students in Seondeok High School. The students are numbered without duplication.
Each student has a crush on exactly one other student, not themselves. The teacher knows this information only for some students; for the remaining students, the teacher does not know whom they have a crush on.
When all unknown information is completed, the teacher wants to know the number of possible completions such that exactly pairs of students like each other. A pair of students liking each other means that two distinct students satisfy that has a crush on and has a crush on .
For each test case, compute the answer for every . Since the number of possible completions can be large, print each answer modulo .
Input
The input is given in the following format.
For each test case, represents the information about student . If , then it is unknown whom student has a crush on. If , then student has a crush on student .
Output
For each test case, print integers on one line, separated by spaces.
The -th integer must be the number of possible completions when , modulo .
Constraints
- .
- .
- The sum of over all test cases is at most .
- or ().
- (), except when .