#P7433. High-Speed Road XOR

    ID: 20628 Type: Default 1000ms 256MiB

High-Speed Road XOR

High-Speed Road XOR

B君 likes to race on the Fourth Ring Road when he is in a bad mood. Recalling old friends and the vast universe, he comes up with the following problem. You are given four integers \(n, X, Y, Z\) where \(X\) is a power of 2, \(Y\) a power of 3, \(Z\) a power of 5, and \(1 \le n \le 1000,\;1 \le X \times Y \times Z \le 2000\). Then you are given four arrays of length \(n\): \(\{a_i\}\), \(\{b_i\}\), \(\{c_i\}\) and \(\{r_i\}\) (with \(0 \le a_i,b_i,c_i,r_i \le 10^9\)).

For each index \(i\) (\(1 \le i \le n\)) you want to choose nonnegative integers \(dx_i, dy_i, dz_i\) such that

[ a_i \le x_i = a_i+dx_i, \quad b_i \le y_i = b_i+dy_i, \quad c_i \le z_i = c_i+dz_i, ]

and the extra condition

[ dx_i+dy_i+dz_i \le r_i. ]

Let (F(u,v,w)) be the number of ways to choose all ({dx_i,dy_i,dz_i}) (for (1\le i\le n)) satisfying the above such that

[ \left(\sum_{i=1}^n (a_i+dx_i)\right) \bmod X = u, \quad \left(\sum_{i=1}^n (b_i+dy_i)\right) \bmod Y = v, \quad \left(\sum_{i=1}^n (c_i+dz_i)\right) \bmod Z = w. ]

The final answer to output is defined as

[ ans = \bigoplus_{0\le u<X,;0\le v<Y,;0\le w<Z}\Bigl( (u\cdot Y\cdot Z+v\cdot Z+w) \times (F(u,v,w) \bmod 466560001) \Bigr), ]

where (\oplus) denotes the bitwise XOR operation.

Note: Since the numbers of solutions can be huge, all intermediate counts should be taken modulo \(466560001\) when used in the final XOR calculation.

inputFormat

The first line contains four integers \(n, X, Y, Z\). It is guaranteed that \(X\) is a power of 2, \(Y\) is a power of 3, \(Z\) is a power of 5, and \(1 \le n \le 1000,\;1\le X\times Y\times Z \le 2000\).

The next four lines each contain \(n\) space‐separated integers. The first line is \(a_1, a_2, \dots, a_n\); the second line is \(b_1, b_2, \dots, b_n\); the third line is \(c_1, c_2, \dots, c_n\); the fourth line is \(r_1, r_2, \dots, r_n\) (with \(0\le a_i,b_i,c_i,r_i\le10^9\)).

outputFormat

Output a single integer, which is the computed XOR value defined by

[ \bigoplus_{0\le u<X,;0\le v<Y,;0\le w<Z}\Bigl( (uY,Z+vZ+w) \times (F(u,v,w) \bmod 466560001) \Bigr). ]

sample

1 2 3 5
0
0
0
0
0