You are given an infinite sequence P, where the i-th member is defined as follows:
P[i] = (A[i % A.size] ^ (B[i % B.size] + i / B.size)) % 1000000007
where % denotes modulo, ^ denotes exponentiation, / denotes integer division, and X.size represents the number of elements in X.
Alternatively, the following pseudocode can be used to calculate the elements of P successively:
int i = 0;
P[i] = (A[i % A.size] ^ B[i % B.size]) % 1000000007;
B[i % B.size] = B[i % B.size] + 1;
i = i + 1;
end of loop
You are given ints A and B, and a String N containing an integer. Calculate the sum of the first N elements of the sequence (i.e., P + P + ... + P[N - 1]), and return that sum modulo 1000000007.