Problem description James has been studying mathematical problems since he said goodbye to ACM/ICPC. He will be able to prepare for the next postgraduate entrance exam and take this opportunity to help some students, especially beautiful teachers and sisters. This is not the case. The only girl in the class asked James for another math question. James was very happy to accept it. After he carefully read the question, he found that he would not do it. Now James said: if the reply says he doesn't understand it, isn't it very shameless?
Therefore, he asks you privately to solve this problem. The problem is as follows:
Give you n numbers, respectively A1, A2, A3, A4, A5 ...... An, these numbers change every unit time. If the previous unit time number is a1', A2 ', A3 '...... An ', A [I] = A [I-1] '* K (when I = 1, a [1] = A [n]' * K) of the unit time), k indicates the given coefficient.
Now the question is, when the unit time t is calculated, what has the N numbers become? Because the number may be very large, you only need to output the result after the number is 10 ^ 9 + 7.
The first line of input data is a positive integer T, indicating that there are T groups of trial data;
Each data set has two rows. The first row includes three integers n, T, K, where n represents the number of digits, t represents the t unit time, and K represents the coefficient; input n numbers of Ai In the second line, which indicates the start time of each number.
[Technical Specification]
T <= 100
1 <= n <= 10 ^ 4
0 <= T <= 10 ^ 9, where T = 0 indicates the initial state
1 <= k <= 10 ^ 9
1 <= AI <= 10 ^ 9
Output for each group of data, please output the N digits after the t unit time to what, when the output
Between every two numbersOutput a space. Do not output any extra space at the end of the line. For details, see the example.
Sample Input
23 2 51 2 33 0 51 2 3
Sample output
50 75 251 2 3#include<stdio.h>#define mod 1000000007int main(){ int n,m,k,i,t; __int64 aa[60],ans[100005],sum; scanf("%d",&t); while(t--) { scanf("%d%d%d",&n,&m,&k); for(i=1;i<=n;i++) { scanf("%I64d",&ans[i]);ans[i]%=mod; } int tk=m,ti=0,a[60]; while(tk) { a[++ti]=tk%2; tk/=2; } aa[1]=k%mod; for(i=2; i<=ti;i++) aa[i]=(aa[i-1]*aa[i-1])%mod; sum=1; for(i=1; i<=ti; i++) if(a[i]) sum=(sum*aa[i])%mod; tk=m%n; if(tk)printf("%I64d",(ans[n-tk+1]*sum)%mod),ti=n-tk+1; else printf("%I64d",(ans[1]*sum)%mod),ti=1; if(ti==1) for(i=2;i<=n;i++) printf(" %I64d",(ans[i]*sum)%mod); else { i=ti-1; for(ti++; ti<=n; ti++) printf(" %I64d",(ans[ti]*sum)%mod); for(ti=1;ti<=i; ti++) printf(" %I64d",(ans[ti]*sum)%mod); } printf("\n"); } return 0;}