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().strip().split()
    
    Q = int(data[0])  # Number of queries
    results = []
    
    index = 1
    for _ in range(Q):
        x = int(data[index])
        y = int(data[index + 1])
        index += 2
        color = find_color(x, y)
        results.append(color)
    
    # Print all results
    print(" ".join(map(str, results)))

if __name__ == "__main__":
    main()