#include #define debug(x) cerr<<"\tDEBUG: "<<#x<<" = "<<(x)<>=1; p=p*p%P; } return res; } int main(){ // freopen("data.in","r",stdin); // freopen("std.out","w",stdout); int QuQ;cin>>QuQ; while(QuQ--){ scanf("%d%d%d",&a,&b,&k); a=1LL*a*qpow(2,k/2)%P; b=1LL*b*qpow(2,k/2)%P; if(k%2==1){ int tmp1=(a+b)%P; int tmp2=(a-b+P)%P; a=tmp1; b=tmp2; } printf("%d %d\n",a,b); } return 0; } /* a b a+b a-b 2a 2b 1 4 4 2 1 2 1 2 4 0 1 3 0 3 4 0 */