Noodle

아직 제출이 없습니다시간 제한7초메모리 제한1024 MB

문제

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 aa of length nn, where nn is even. The amount of sauce initially at position ii is a_ia\_i.

In one operation, Budada will do the following process.

  1. Budada will fold the noodle, the length of the noodle will become n2\frac{n}{2}, the amount of sauce at position ii will become the sum of the amounts of sauce at positions ii and ni+1n - i + 1. Formally, the amount of sauce at position ii of the new noodle b_ib\_i satisfies b_i=a_i+a_ni+1b\_i = a\_i + a\_{n - i + 1}.
  2. Then Budada will stretch the noodle to the original length, and the amount of sauce will be evenly divided. Formally, the amount of sauce at position ii of the new noodle a_ia\_i' satisfies a_i=12b_i2a\_i' = \frac{1}{2} \cdot {b\_{\left\lceil\frac{i}{2}\right\rceil}}.

Putata has a favorite position on the noodle, which is a certain position xx. Now you are asked to answer qq queries. In the ii-th query, you should output the amount of sauce at position xx after kk operations. The xx is the same for all queries, but kk is given separately for each query.

It can be shown that the answer can be expressed as an irreducible fraction xy\frac{x}{y}, where xx and yy are integers and y≢0(mod998,244,353)y \not \equiv 0 \pmod {998\\,244\\,353}. Output the integer equal to xy1(mod998,244,353)x \cdot y^{-1} \pmod {998\\,244\\,353}. In other words, output such an integer aa that 0a<998,244,3530 \leq a < 998\\,244\\,353 and ayx(mod998,244,353)a \cdot y \equiv x \pmod {998\\,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_ii)\oplus\_{i = 1}^q (\mathit{ans}\_i\cdot i). Please notice that this number is not taken modulo 998,244,353998\\,244\\,353. Here, \oplus means bitwise exclusive-or operation.

입력

The first line contains three integers test\mathit{test}, TT, and seed\mathit{seed}, which are an unrelated variable, the number of test cases, and the seed for generating test data. Please note that test\mathit{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 nn, qq, xx, and k_maxk\_{\max} (1n21061 \leq n \leq 2 \cdot 10^6, 1q51071 \leq q \leq 5 \cdot 10^7, 1xn1 \leq x \leq n, 1k_max10181 \leq k\_{\max} \leq 10^{18}).

The second line contains nn integers, the ii-th integer is a_ia\_i (0a_i<998,244,3530 \leq a\_i < 998\\,244\\,353).

It is guaranteed that n2106\sum n \leq 2 \cdot 10^6, q5107\sum q \leq 5 \cdot 10^7, and nn is even.

출력

Output TT lines. The ii-th line must contain the answer to the ii-th test case.

힌트

In the first test case of the sample, a_i\\{a\_i\\} are 1,4,2,3\\{1,4,2,3\\} initially.

  • After one operation, it becomes 2,2,3,3\\{2,2,3,3\\}.
  • After two operations, it becomes 52,52,52,52\\{\frac{5}{2},\frac{5}{2},\frac{5}{2},\frac{5}{2}\\}.
  • The generated queries are:
  • The position is x=1x = 1;
  • The first query: k=0k = 0, a_x=1a\_x = 1;
  • The second query: k=1k = 1, a_x=2a\_x = 2;
  • The answer is (11)(22)=5(1 \cdot 1) \oplus (2 \cdot 2) = 5.

In the second test case, a_i\\{ a\_i \\} is 6,2,5,3,1,4\\{ 6, 2, 5, 3, 1, 4 \\} initially.

  • After one operation, it becomes 5,5,32,32,4,4\\{ 5, 5, \frac{3}{2}, \frac{3}{2}, 4, 4 \\}.
  • After two operations, it becomes 92,92,92,92,32,32\\{ \frac{9}{2}, \frac{9}{2}, \frac{9}{2}, \frac{9}{2}, \frac{3}{2}, \frac{3}{2} \\}.
  • The generated queries are:
  • The position is x=3x = 3;
  • The first query: k=2k = 2, a_x=92a\_x = \frac{9}{2}, and 92499,122,181(mod998,244,353)\frac{9}{2} \equiv 499\\,122\\,181 \pmod{998\\,244\\,353};
  • The second query: k=0k = 0, a_x=5a\_x = 5.
  • The answer is (499,122,1811)(52)=499,122,18110=499,122,191(499\\,122\\,181 \cdot 1) \oplus (5 \cdot 2) = 499\\,122\\,181 \oplus 10 = 499\\,122\\,191.

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.
      */
    }
  }
}