#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); 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; static array memo = {}; assert (frac % 2 == 1); if (not memo[frac]) { memo[frac] = powmod(frac, MOD/2-1, MOD); memo[memo[frac]] = frac; } return make_pair(memo[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; } pair factmod(int n) { static array, 2*MOD> memo = {}; if (not memo[1].first) { memo[0] = { 1, 0 }; repeat (i,2*MOD-1) memo[i+1] = mult(memo[i], split(i+1)); } return memo[n]; } int choose_modulo(int n, int r) { return merge(mult(factmod(n), inv(mult(factmod(n-r), factmod(r))))); } bool solve(int a, int b, int c) { assert (a <= A_MAX); if (c % 2 == 0) return 0; int d = c *(ll) choose_modulo(c+b-1, b) % 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; }