#include #include #define ll long long using namespace std; const int inf = 1e9; const int N = 300007; const int mod = 998244353; const double eps = 1e-6; const double pi = acos(-1.0); #define pa pair #define rep(i, a, b) for(int i=(a);i<=(b);++i) #define per(i, a, b) for(int i=(a);i>=(b);--i) #define ms(a, b) memset(a, b, sizeof a) inline int read(){ int x; scanf("%d", &x); return x; } int T, n, m; int k; int ksm(int a, int b){ int res = 1; while(b){ if(b & 1)res = 1ll * res * a % mod; a = 1ll * a * a % mod; b >>= 1; } return res; } void slove(int x, int y, int z) { if(z & 1){ int key1 = 1ll * (x + y) * ksm(2, (k - 1) / 2) % mod; int key2 = 1ll * (x - y) * ksm(2, (k - 1) / 2) % mod; key1 = (key1 % mod + mod) % mod; key2 = (key2 % mod + mod) % mod; printf("%d %d\n", key1, key2); } else { int key1 = 1ll * x * ksm(2, k / 2) % mod; int key2 = 1ll * y * ksm(2, k / 2) % mod; key1 = (key1 % mod + mod) % mod; key2 = (key2 % mod + mod) % mod; printf("%d %d\n", key1, key2); } } signed main() { T = read(); while(T--){ n = read(), m = read(), k = read(); if(n == m){ if(k & 1){ int key = 1ll * n * ksm(2, (k + 1) / 2) % mod; printf("%d 0\n", key); } else { int key = 1ll * n * ksm(2, k / 2) % mod; printf("%d %d\n", key, key); } continue; } slove(n, m, k); } }