fork download
  1. def find_color(x, y):
  2. # Determine color based on the rules derived from triangle construction
  3. if x % 2 == 1:
  4. return 1 # Red
  5. else:
  6. return 0 # Blue
  7.  
  8. def main():
  9. import sys
  10. input = sys.stdin.read
  11. data = input().splitlines()
  12.  
  13. Q = int(data[0]) # Number of queries
  14. results = []
  15.  
  16. for i in range(1, Q + 1):
  17. x, y = map(int, data[i].split())
  18. color = find_color(x, y)
  19. results.append(color)
  20.  
  21. # Print all results
  22. sys.stdout.write("\n".join(map(str, results)) + "\n")
  23.  
  24. if __name__ == "__main__":
  25. main()
Success #stdin #stdout 0.04s 9944KB
stdin
6
1 1
5 3
8 2
8 6
5 4
6 4
stdout
1
1
0
0
1
0