#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline int read()
{
	char ch=getchar(); int ne=0; while(!isdigit(ch)) {if(ch=='-') ne=1; ch=getchar();}
	int ans=0; while(isdigit(ch)) ans=ans*10+ch-'0',ch=getchar();
	if(ne) return -ans;
	else return ans;
}
#define mod 998244353
inline int add(int x,int y) {return x+y>=mod?x+y-mod:x+y;}
inline int sub(int x,int y) {return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y) {return 1LL*x*y%mod;}
inline int add(int x,int y,int z) {return add(add(x,y),z);}
inline int mul(int x,int y,int z) {return mul(mul(x,y),z);}
int qpow(int x,ll y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=mul(ans,x);
		x=mul(x,x),y>>=1;
	}
	return ans;
}
int Inv(int x) {return qpow(x,mod-2);}
unsigned long long _seed;
unsigned long long rd(unsigned long long &x) {
	x ^= (x << 13);
	x ^= (x >> 7);
	x ^= (x << 17);
	return x;
}
#define N 2000005
const int i2=(mod+1)/2;
int a[N],b[N],n,Q,x;
struct Query{int v,id;};
Query q[N];
bool cmp(Query x,Query y) {return x.v<y.v;}
void trans()
{
	for(int i=1;i<=n/2;i++) b[i]=add(a[i],a[n-i+1]);
	for(int i=1;i<=n/2;i++) a[i*2-1]=a[i*2]=b[i];
}
void work()
{
	long long k_max;
	cin>>n>>Q>>x>>k_max;
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i = 1; i <= Q; i ++)
	{
		long long k = rd(_seed) % k_max;
		q[i].id=i,q[i].v=k;
	}
	sort(q+1,q+Q+1,cmp);
	int cur=1,ipw=1;
	ll ans=0;
	for(int i=0;i<k_max;i++)
	{
		int res=mul(a[x],ipw);
		while(cur<=Q&&q[cur].v==i) ans^=1LL*q[cur].id*res,cur++;
		trans(); ipw=mul(ipw,i2);
		for(int i=1;i<=n;i+=2) printf("%d%c",a[i]," \n"[i==n-1]);
	}
//	printf("%lld\n",ans);
}

signed main() {
	freopen("noodle.in","r",stdin);
//	freopen("noodle.out","w",stdout);
	int test, T;
	scanf("%d%d%llu", &test, &T, &_seed);
	for(int Case = 1; Case <= T; Case ++) work();
}
