#include using namespace std; #define ll long long #define db double #define X first #define Y second #define rep(i,a,b) for(int i=(a);i<=(b);++i) #define rep0(i,a,b) for(int i=(a);i<(b);++i) #define per(i,a,b) for(int i=(a);i>=(b);--i) #define fore(i,a) for(int i=0;i>=1,a=1ll*a*a%P)if(b&1)r=1ll*r*a%P;return r; } int main() { int T=rd(); while(T--) { int a,b,k; a=rd();b=rd();k=rd(); int t=k&1;k>>=1; int s=pw(2,k); a=1ll*a*s%P; b=1ll*b*s%P; if(t) { printf("%d %d\n",(a+b)%P,(a+P-b)%P); } else printf("%d %d\n",a,b); } return 0; }