

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
typedef long long ll;
typedef std::pair<int,int> pii;
typedef unsigned un;
ll read()
{
	ll x=0;bool f=0;int c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=1;c=getchar();}
	while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
	return f?-x:x;
}

const int mod = 998244353,inv2=(mod+1)>>1;
struct Mint
{
	int x;
	Mint(){x=0;}
	Mint(ll y)
	{
		if(0<=y&&y<mod)x=y;
		else x=(y%mod+mod)%mod;
	}
	void operator+= (Mint you){x+=you.x;if(x>=mod)x-=mod;}
	void operator-= (Mint you){x-=you.x;if(x<0)x+=mod;}
	void operator*= (Mint you){x=ll(x)*you.x%mod;}
};
Mint operator+ (Mint a,Mint b){int t=a.x+b.x;return t>=mod?t-mod:t;}
Mint operator- (Mint a,Mint b){int t=a.x-b.x;return t<0?t+mod:t;}
Mint operator* (Mint a,Mint b){return ll(a.x)*b.x%mod;}

unsigned long long rd(unsigned long long &x) {
	x ^= (x << 13);
	x ^= (x >> 7);
	x ^= (x << 17);
	return x;
}

const int MAXN = 2000011,L = 155;
struct matrix
{
	int a[L][L];
	matrix(){memset(a,0,sizeof a);}
	matrix operator* (const matrix& you)
	{
		matrix res;
		for(int i=1;i<L;++i)
			for(int k=1;k<L;++k)
				for(int j=1;j<L;++j)
					res.a[i][j]=(res.a[i][j]+ll(a[i][k])*you.a[k][j])%mod;
		return res;
	}
}A[60];
int res[L],nxt[L];

namespace Brute
{
	int a[MAXN],b[MAXN];
	int mem[MAXN];
	void solve(unsigned long long& seed)
	{
		int n=read(),q=read(),x=read();
		ll k_max=read();
		for(int i=1;i<=n;++i)a[i]=read();
		mem[0]=a[x];
		for(int k=1;k<=k_max;++k)
		{
			for(int i=1;i<=(n>>1);++i)b[i]=(a[i]+a[n-i+1])%mod;
			for(int i=1;i<=n;++i)a[i]=ll(b[(i+1)>>1])*inv2%mod;
			mem[k]=a[x];
		}
		ll ans=0;
		for(int i=1;i<=q;++i)
		{
			long long k = rd(seed) % k_max;
			ans^=ll(mem[k])*i;
		}
		printf("%lld\n",ans);
	}
}
int a[MAXN];
int main() {
	freopen("noodle.in","r",stdin);
	freopen("noodle.out","w",stdout);
	int test, T;
	unsigned long long seed;
	scanf("%d%d%llu", &test, &T, &seed);
	for(int Case = 1; Case <= T; Case ++) {
		Brute::solve(seed);
	}
	return 0;
}
