# 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 ext_gcd(a, b): u = y = 1 v = x = 0 while a != 0: q = b // a u, x = x-q*u, u v, y = y-q*v, v a, b = b-q*a, a return [x,y] def minv(n, m): return ext_gcd(n, m)[0] mod = 2 ** 21 fact_factor2 = [0] * mod fact_mod = [0] * mod fact_mod[0] = 1 for i in range(1, mod): j = i f2 = 0 while j % 2 == 0: f2 += 1 j = j // 2 fact_mod[i] = fact_mod[i-1] * j % mod fact_factor2[i] = fact_factor2[i-1] + f2 # totient # totient_table = [0] * mod # for i in range(1, mod): # totient_table[i] = i # for i in range(1, mod): # if totient_table[i] == i: # for j in range(i, mod, i): # totient_table[j] = totient_table[j] // i * (i - 1) # def minv2(n, m): # return pow(n, totient_table[m] - 1, m) def totient(n): res = n for i in range(2, n): if i*i > n: break if n % i == 0: res = res // i * (i - 1) while n % i == 0: n = n // i if n != 1: res = res // n * (n - 1) return res totient_mod = totient(mod) def minv2(n): return pow(n, totient_mod - 1, mod) def solve(A, B, C): if C % 2 == 0: 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 = fact_mod[C+B-1] * minv2(fact_mod[B]) % mod * minv2(fact_mod[C-1]) % 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))