def find_color(x, y):
# Determine color based on the rules derived from triangle construction
if x % 2 == 1:
return 1 # Red
else:
return 0 # Blue
def main():
import sys
input = sys.stdin.read
data = input().splitlines()
Q = int(data[0]) # Number of queries
results = []
for i in range(1, Q + 1):
x, y = map(int, data[i].split())
color = find_color(x, y)
results.append(color)
# Print all results
sys.stdout.write("\n".join(map(str, results)) + "\n")
if __name__ == "__main__":
main()
ZGVmIGZpbmRfY29sb3IoeCwgeSk6CiAgICAjIERldGVybWluZSBjb2xvciBiYXNlZCBvbiB0aGUgcnVsZXMgZGVyaXZlZCBmcm9tIHRyaWFuZ2xlIGNvbnN0cnVjdGlvbgogICAgaWYgeCAlIDIgPT0gMToKICAgICAgICByZXR1cm4gMSAgIyBSZWQKICAgIGVsc2U6CiAgICAgICAgcmV0dXJuIDAgICMgQmx1ZQoKZGVmIG1haW4oKToKICAgIGltcG9ydCBzeXMKICAgIGlucHV0ID0gc3lzLnN0ZGluLnJlYWQKICAgIGRhdGEgPSBpbnB1dCgpLnNwbGl0bGluZXMoKQogICAgCiAgICBRID0gaW50KGRhdGFbMF0pICAjIE51bWJlciBvZiBxdWVyaWVzCiAgICByZXN1bHRzID0gW10KICAgIAogICAgZm9yIGkgaW4gcmFuZ2UoMSwgUSArIDEpOgogICAgICAgIHgsIHkgPSBtYXAoaW50LCBkYXRhW2ldLnNwbGl0KCkpCiAgICAgICAgY29sb3IgPSBmaW5kX2NvbG9yKHgsIHkpCiAgICAgICAgcmVzdWx0cy5hcHBlbmQoY29sb3IpCiAgICAKICAgICMgUHJpbnQgYWxsIHJlc3VsdHMKICAgIHN5cy5zdGRvdXQud3JpdGUoIlxuIi5qb2luKG1hcChzdHIsIHJlc3VsdHMpKSArICJcbiIpCgppZiBfX25hbWVfXyA9PSAiX19tYWluX18iOgogICAgbWFpbigp