#P8525. Operation Sequence XOR

    ID: 21693 Type: Default 1000ms 256MiB

Operation Sequence XOR

Operation Sequence XOR

You are given m operations. For the i-th operation you are provided eight integers: \(L_i, R_i, a_i, b_i, l_i, r_i, X_i, x_i\). For each operation, you must perform an iterative process and output the bitwise XOR of two computed values.

For the i-th operation, define the initial state as \((x_i, 0)\). Then, for each integer \(j\) ranging from \(l_i\) to \(r_i\) (inclusive), update the state \((x,y)\) by applying the function \(F_{i,j}\) defined as follows:

[ F_{i,j}(x,y)= \begin{cases} \bigl((a_j \cdot x + b_j) \bmod 2677114440,; \max(b_j, y)\bigr) & \text{if } L_j \le X_i \le R_j,
(x,y) & \text{otherwise.} \end{cases} ]

After processing all functions from \(j=l_i\) to \(r_i\), let the final state be \((ans_{i,0},ans_{i,1})\). The answer for the i-th operation is defined as:

[ ans_{i,0} \oplus ans_{i,1} ]

Process all operations and output the corresponding answers, one per line.

inputFormat

The first line contains an integer m, the number of operations. Each of the following m lines contains eight space‐separated integers: \(L_i\), \(R_i\), \(a_i\), \(b_i\), \(l_i\), \(r_i\), \(X_i\), and \(x_i\).

Note: The operations are 1-indexed. In the iterative process for the i-th operation, the parameter values \(L_j, R_j, a_j, b_j\) used in function \(F_{i,j}\) are from the j-th operation.

outputFormat

Output m lines, where the i-th line contains the answer for the i-th operation, computed as \(ans_{i,0} \oplus ans_{i,1}\).

sample

2
1 10 2 3 1 2 5 7
4 20 5 2 2 2 10 0
84

0

</p>