import std.conv, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken().to!int; } long readLong() { return readToken().to!long; } real readReal() { return readToken().to!real; } void chmin(T)(ref T t, in T f) { if (t > f) t = f; } void chmax(T)(ref T t, in T f) { if (t < f) t = f; } int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; } int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); } int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); } // a^-1 (mod 2^64) long modInv(long a) in { assert(a & 1, "modInv: a must be odd"); } do { long b = ((a << 1) + a) ^ 2; b *= 2 - a * b; b *= 2 - a * b; b *= 2 - a * b; b *= 2 - a * b; return b; } /* C * H(C * H(C, B), A) */ immutable LIM = 2 * 10^^6 + 10; long[] facTwo, facOdd; void main() { facTwo = new long[LIM]; facOdd = new long[LIM]; facTwo[0] = 0; facOdd[0] = 1; foreach (i; 1 .. LIM) { facTwo[i] = facTwo[i - 1] + bsf(i); facOdd[i] = facOdd[i - 1] * (i >> bsf(i)); } const numCases = readInt(); foreach (caseId; 0 .. numCases) { const A = readInt(); const B = readInt(); const C = readInt(); // binom(C + B - 1, B) mod 2^64 const shift = facTwo[C + B - 1] - facTwo[C - 1] - facTwo[B]; long p = facOdd[C + B - 1] * modInv(facOdd[C - 1] * facOdd[B]); debug{ writeln("shift = ",shift); } p = (shift < 64) ? (p << shift) : 0; p = C * p + A - 1; debug{ writeln("p = ",p); } long ans = 1; foreach (i; 0 .. bsr(A) + 1) { if (!((p >> i) & 1) && ((A >> 1) & 1)) { ans = 0; } } (ans *= C) %= 2; writeln(ans); } }