#include<stdio.h> #include<string.h> #define mod 1000000007 int a[10100]; int b[10100]; int multy(int q,int n) { int base=q; int ret =1; while(n>0) { if(n&1)ret=(long long)ret*base%mod; n>>=1; base=(long long)base*base%mod; } return ret; } int main() { int _case; int n,t,k; int i; scanf("%d",&_case); while(_case--) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); scanf("%d %d %d",&n,&t,&k); for(i=0;i<n;i++) scanf("%d",&a[i]); int tmp=t; t=t%n;//a[i]的循环变换 for(i=0;i<n-t;i++) b[i+t]=a[i]; int j=i; for(;i<n;i++) b[i-j]=a[i]; /* for(i=0;i<n;i++) printf("%d\n",b[i]);*/ int ans=multy(k,tmp); for(i=0;i<n;i++) b[i]=(long long)b[i]*ans%mod; printf("%d",b[0]); for(i=1;i<n;i++) printf(" %d",b[i]); printf("\n"); } return 0; }