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()