Hierarchy
In a certain organization, there are n employees. We define that employee A is a subordinate of employee B if:
1. A is a direct subordinate of B, or
2. There exists an employee C such that A is a direct subordinate of C, and C is a subordinate of B.
No employee can be their own subordinate. Messages within the organization can be exchanged between A and B only if A is a subordinate of B, or vice versa. The organizational structure allows messages to be transmitted between any two employees. Your task is to determine, for given employees A and B, whether A is a subordinate of B, B is a subordinate of A, or if there is no subordinate relationship between them.
Input
The first line of the input specifies the number of employees n and the number of queries q. The second and third lines provide the query parameters X, a, b and Y, c, d. Following this, n lines describe the organizational structure. For the i-th employee, the (i + 3)-th line lists their direct subordinates: k_i — the number of direct subordinates, followed by the identifiers of these k direct subordinates. Employees are numbered from 0 to n-1. Each query is of the form (x_j, y_j), and the response should be 1 if y_j is a subordinate of x_j, 1 if x_j is a subordinate of y_j, or 0 if no subordinate relationship exists between them.
Here, x_0 = X, y_0 = Y, xj = (ax_{j-1} + b + sum_{j-1}) mod n, yj = (cy_{j-1} + d + sum_{j-1}) mod n, where j = 1...q-1, and sum_{j-1} is the sum of the moduli of the answers to the first j-1 queries.
Constraints
1 ≤ n ≤ 10^5
1 ≤ q ≤ 5·10^5
0 ≤ X, a, b, Y, c, d < n
n-1 ≤ k_i < n+100
Output
For each query, output the result on a separate line, as described above.