#include #include #include #include #define repeat(i,n) for (int i = 0; (i) < int(n); ++(i)) typedef long long ll; using namespace std; ll powmod(ll x, ll y, ll p) { // O(log y) assert (y >= 0); x %= p; if (x < 0) x += p; ll z = 1; for (ll i = 1; i <= y; i <<= 1) { if (y & i) z = z * x % p; x = x * x % p; } return z; } const int A_MAX = 1000000; const int MOD = 1048576; // pow(2, floor(log2(A_MAX)) + 1); int invmod(int n) { static array memo = {}; assert (n % 2 == 1); if (not memo[n]) memo[n] = powmod(n, MOD/2-1, MOD); return memo[n]; } pair split(int x) { if (x == 0) return make_pair(0, 0); int ctz = __builtin_ctz(x); return make_pair(x >> ctz, ctz); } pair inv(pair it) { int frac, expo; tie(frac, expo) = it; return make_pair(invmod(frac), - expo); } pair mult(pair a, pair b) { int a_frac, a_expo; tie(a_frac, a_expo) = a; int b_frac, b_expo; tie(b_frac, b_expo) = b; return make_pair(a_frac *(ll) b_frac % MOD, a_expo + b_expo); } int merge(pair it) { int frac, expo; tie(frac, expo) = it; assert (expo >= 0); while (expo --) frac = frac * 2 % MOD; return frac; } int choose_modulo(int n, int r) { pair acc = split(1); repeat (i,r) acc = mult(acc, mult(split(n-i), inv(split(i+1)))); return merge(acc); } bool solve(int a, int b, int c) { assert (a <= A_MAX); if (c % 2 == 0) return 0; ll d = c *(ll) choose_modulo(c+b-1, b) % MOD + MOD; return choose_modulo(d+a-1, a) % 2; } int main() { int t; cin >> t; while (t --) { int a, b, c; cin >> a >> b >> c; cout << solve(a, b, c) << endl; } return 0; }