def ext_gcd(a, b): if b == 0: return [1, 0] else: y, x = ext_gcd(b, a % b) return [x, y - (a // b) * x] def minv(n, m): return ext_gcd(n, m)[0] mod = 2 ** 21 fact_factor2 = list() fact_mod = list() fact_factor2.append(0) fact_mod.append(1) for i in range(1, mod): j = i f2 = 0 while j % 2 == 0: f2 += 1 j = j // 2 fact_mod.append(fact_mod[i-1] * j % mod) fact_factor2.append(fact_factor2[i-1] + f2) def solve(A, B, C): if C == 2: return 0 else: f2 = fact_factor2[C+B-1] - fact_factor2[B] - fact_factor2[C-1] val = fact_mod[C+B-1] * minv(fact_mod[B], mod) % mod * minv(fact_mod[C-1], mod) % mod val = ((C * val % mod) << min(32, f2)) % mod + A - 1 if (val & A) == A: return 1 else: return 0 testcase = int(input()) for _ in range(testcase): A, B, C = list(map(int, input().split())) print(solve(A, B, C))