#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template static void amin(T &x, U y) { if (y < x) x = y; } template static void amax(T &x, U y) { if (x < y) x = y; } #pragma GCC optimize ("O3") #pragma GCC target ("sse4") unsigned inv2adic(unsigned x) { unsigned i = x, p; do { p = i * x; i *= 2U - p; } while (p != 1); return i; } inline int popcount(unsigned x) { #ifdef __GNUC__ return __builtin_popcount(x); #else return _mm_popcnt_u32(x); #endif } int main() { int T; scanf("%d", &T); const int N = 2000000; vector fact(N + 1); fact[0] = 1; rep(i, N) { unsigned x = i + 1; while ((x & 1) == 0) x >>= 1; fact[i + 1] = fact[i] * x; } for (int ii = 0; ii < T; ++ii) { int A; int B; int C; scanf("%d%d%d", &A, &B, &C); //C(C(c+b-1,b) * c + a - 1, a) * c int n = C + B - 1, r = B; int val = 0; val -= popcount(n); val += popcount(r); val += popcount(n - r); unsigned x = fact[n] * inv2adic(fact[r] * fact[n - r]); x <<= min(val, 30); x *= C; x += A - 1; int ans = (A & ~x) == 0 && C % 2 == 1 ? 1 : 0; printf("%d\n", ans); } return 0; }