#include using namespace std; typedef long long ll; ll mod = 998244353; ll pow_(ll x, ll y, ll mod) { ll ans = 1; ll base = x % mod; while(y) { if(y & 1 != 0) ans = ((ans%mod) * (base %mod))%mod; y = y >> 1; base = ((base%mod) * (base % mod) )%mod; } return ans % mod; } int main() { int T; scanf("%d", &T); while(T--) { ll a, b, k; scanf("%lld%lld%lld", &a, &b, &k); ll num = k / 2; ll add_ = k % 2; ll ansa = a; ll ansb = b; if(k > 0) { ansa = ((a%mod) * (pow_(2, num, mod)%mod)) % mod; ansb = ((b%mod) * (pow_(2, num, mod)%mod)) % mod; } if(add_ == 0) { cout << (ansa + mod)%mod << " " << (ansb + mod)%mod << endl; } else { cout << (ansa + ansb + mod)%mod << " " << (ansa - ansb + mod)%mod << endl; } } return 0; }