image.png

문제 설명

문제 태그

아이디어

  1. 주어진 켜진전구 좌표를 전부 xor 해보면 좌표가 복원 됨.
  2. 이는 토글되는 점이 4개이기 때문에 xor 연산에 의해 상쇄되기 때문. 만약 3개였다면 안통함

정답

import sys
input = sys.stdin.readline

t = int(input())
for _ in range(t):
    n = int(input())
    sx = 0
    sp = 0
    for _ in range(n):
        x, y = map(int, input().split())
        sx ^= x
        sp ^= x + y
    print(sx, sp - sx)