Putata is a boy who loves eating noodles. Now he's waiting for the great chef Budada to cook the most delicious noodle ever for him.
The noodle which Budada is cooking for him can be described as an array a of length n, where n is even. The amount of sauce initially at position i is a_i.
In one operation, Budada will do the following process.
Putata has a favorite position on the noodle, which is a certain position x. Now you are asked to answer q queries. In the i-th query, you should output the amount of sauce at position x after k operations. The x is the same for all queries, but k is given separately for each query.
It can be shown that the answer can be expressed as an irreducible fraction yx, where x and y are integers and y≡0(mod998,244,353). Output the integer equal to x⋅y−1(mod998,244,353). In other words, output such an integer a that 0≤a<998,244,353 and a⋅y≡x(mod998,244,353).
Since the input is quite large, you will have to use a generator to generate the queries, and you only have to output ⊕_i=1q(ans_i⋅i). Please notice that this number is not taken modulo 998,244,353. Here, ⊕ means bitwise exclusive-or operation.
The first line contains three integers test, T, and seed, which are an unrelated variable, the number of test cases, and the seed for generating test data. Please note that test will not be used to solve the problem, you can just ignore it. The generator code is given further below.
For each test case, the input will contain two lines.
The first line contains four integers n, q, x, and k_max (1≤n≤2⋅106, 1≤q≤5⋅107, 1≤x≤n, 1≤k_max≤1018).
The second line contains n integers, the i-th integer is a_i (0≤a_i<998,244,353).
It is guaranteed that ∑n≤2⋅106, ∑q≤5⋅107, and n is even.
Output T lines. The i-th line must contain the answer to the i-th test case.
In the first test case of the sample, a_i are 1,4,2,3 initially.
In the second test case, a_i is 6,2,5,3,1,4 initially.
The generator will be given below:
#include <bits/stdc++.h>
using namespace std;
unsigned long long rd (unsigned long long &x) {
x ^= (x << 13);
x ^= (x >> 7);
x ^= (x << 17);
return x;
}
int main () {
int test, T;
unsigned long long seed;
scanf("%d%d%llu", &test, &T, &seed);
for (int Case = 1; Case ≤ T; Case ++) {
int n, q, x;
long long k_max;
scanf("%d%d%d%lld", &n, &q, &x, &k_max);
vector<int> a(n + 1);
for (int i = 1; i ≤ n; i ++) {
scanf("%d", &a[i]);
}
for (int i = 1; i ≤ q; i ++) {
long long k = rd(seed) % k_max;
/*
Code your solution here.
*/
}
}
}