def find_color(x):
# Determine color based on the value of x
return 1 if x % 2 == 1 else 0
def main():
import sys
input = sys.stdin.read
data = input().strip().split()
Q = int(data[0]) # Number of queries
results = []
index = 1
for _ in range(Q):
x = int(data[index])
# y is not used in the color determination
index += 2
color = find_color(x)
results.append(color)
# Print all results
print(" ".join(map(str, results)))
if __name__ == "__main__":
main()
ZGVmIGZpbmRfY29sb3IoeCk6CiAgICAjIERldGVybWluZSBjb2xvciBiYXNlZCBvbiB0aGUgdmFsdWUgb2YgeAogICAgcmV0dXJuIDEgaWYgeCAlIDIgPT0gMSBlbHNlIDAKCmRlZiBtYWluKCk6CiAgICBpbXBvcnQgc3lzCiAgICBpbnB1dCA9IHN5cy5zdGRpbi5yZWFkCiAgICBkYXRhID0gaW5wdXQoKS5zdHJpcCgpLnNwbGl0KCkKICAgIAogICAgUSA9IGludChkYXRhWzBdKSAgIyBOdW1iZXIgb2YgcXVlcmllcwogICAgcmVzdWx0cyA9IFtdCiAgICAKICAgIGluZGV4ID0gMQogICAgZm9yIF8gaW4gcmFuZ2UoUSk6CiAgICAgICAgeCA9IGludChkYXRhW2luZGV4XSkKICAgICAgICAjIHkgaXMgbm90IHVzZWQgaW4gdGhlIGNvbG9yIGRldGVybWluYXRpb24KICAgICAgICBpbmRleCArPSAyCiAgICAgICAgY29sb3IgPSBmaW5kX2NvbG9yKHgpCiAgICAgICAgcmVzdWx0cy5hcHBlbmQoY29sb3IpCiAgICAKICAgICMgUHJpbnQgYWxsIHJlc3VsdHMKICAgIHByaW50KCIgIi5qb2luKG1hcChzdHIsIHJlc3VsdHMpKSkKCmlmIF9fbmFtZV9fID09ICJfX21haW5fXyI6CiAgICBtYWluKCk=