#include<bits/stdc++.h>
const int maxn = 2e2+5;
const int mod = 1e9+7;
using namespace std;
typedef long long ll;
typedef struct
{
int s[maxn][maxn];
}matrix;
int n,k,a[maxn];
ll m;
matrix mul(matrix A,matrix B)
{ matrix ans;
memset(ans.s,0,sizeof(ans.s));
for(int i = 0 ;i < n;i++)
for(int j =0;j < n;j++)
{
for(int k = 0; k < n;k++)
{
ans.s[i][k] = (ans.s[i][k]+(ll)A.s[i][j]*B.s[j][k] % mod)%mod;
if(ans.s[i][k] < 0) ans.s[i][k] += mod;
}
}
return ans;
}
matrix quickpow(matrix A,ll x)
{
matrix E;
for(int i = 0;i < n;i++)
for(int j = 0;j < n;j++)
{ if(i == j)
E.s[i][j] = 1;
else
E.s[i][j] = 0;
}//初始化,数初始化为1,矩阵应该初始化为单位矩阵;
while(x){
if(x&1)
{
E=mul(E,A);
}
A=mul(A,A);
x /= 2;
}
return E;
}
int main()
{
int _;
cin >> _;
while(_--)
{
scanf("%d %lld %d",&n,&m,&k);
for(int i = 0;i < n;++i)
scanf("%d",&a[i]);
matrix mid ;
memset(mid.s,0,sizeof mid.s);
for(int i =0;i < n;++i)
{
for(int j = 0;j < n;++j)
{
if(i == j) mid.s[i][j] = 0;
else
mid.s[i][j] = k - min(n - abs(j - i),abs(i - j));
}
}
mid = quickpow(mid,m);
matrix ans;
memset(ans.s,0,sizeof ans.s);
for(int i = 0;i < n;++i)
ans.s[0][i] = a[i];
ans = mul(ans,mid);
for(int i = 0;i < n;++i)
printf("%d%c",ans.s[0][i],i == n - 1?'\n':' ');
}
return 0;
}