#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e6 + 10;
const int P = 998244353;
unsigned long long rd(unsigned long long &x) {
	x ^= (x << 13);
	x ^= (x >> 7);
	x ^= (x << 17);
	return x;
}
int power(int a, int b, int c = 1) {
    for(; b; b >>= 1, a = (ll)a * a % P) if(b & 1) c = (ll)c * a % P;
    return c;
}
const int K = 30;
vector<int> coef[K];
int main() {
    freopen("noodle.in", "r", stdin);
    freopen("noodle.out", "w", stdout);
    int inv = power(2, P - 2);
	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]);
		}
        coef[0].clear();
        coef[0].resize(n);
        for(int i = 0; i < n; i++) coef[0][i] = a[i];
        for(int i = 0; i < K - 1; i++) {
            coef[i + 1].clear();
            coef[i + 1].resize(n);
            for(int j = 0; j < n; j++) {
                int y;
                if(j < n / 2) y = j;
                else y = n - 1 - j;
                (coef[i + 1][y * 2] += (ll)coef[i][j] * inv % P) %= P;
                (coef[i + 1][y * 2 + 1] += (ll)coef[i][j] * inv % P) %= P;
            }
        }
		for(int i = 1; i <= q; i ++) {
			long long k = rd(seed) % k_max;
            if(k > K - 1) printf("%d\n", coef[K - 1][x - 1]);
            else printf("%d\n", coef[k][x - 1]);
		}
	}
}