#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;
}

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
inline void read(T &f) {
	f = 0; int fu = 0; char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') fu = 1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		f = f * 10 + (c - '0');
		c = getchar();
	}
	if (fu) f = -f;
}

const int md = 998244353, inv2 = (md + 1) / 2;

inline int add(int x, int y) {
	if (x + y >= md) return x + y - md;
	return x + y;
}

inline int sub(int x, int y) {
	if (x < y) return x - y + md;
	return x - y;
}

inline int mul(int x, int y) { return 1ull * x * y % md; }

inline int fpow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		y >>= 1; x = mul(x, x);
	}
	return ans;
}

const int N = 2e6 + 105;

ull seed;
int a[N], tmp[N * 2], s[30];
int T, n, q, x; ll k_max;

inline int div2(int x) {
	if (x & 1) return (x + md) >> 1;
	return x >> 1;
}

int main() {
	read(T); read(T); read(seed);
	while (T--) {
		read(n); read(q); read(x); read(k_max);
		for(int i = 1; i <= n; i++) read(a[i]), tmp[i] = a[i];
		s[0] = 1; int l = 1, r = n;
		for (int i = 1; i <= 21; i++) {
			int len = r - l + 1, L = r + 1, R = r;
			for (int j = 0; j < len / 2; j++) tmp[++R] = div2(add(tmp[l + j], tmp[r - j]));
			if (len & 1) tmp[++R] = tmp
		}
		for(int i = 1; i <= q; i++) {
			ll k = rd(seed) % k_max;
			
		}
	}
	return 0;
}
