N = int(input()) if N <= 2: print(N, 1) t = int(input()) exit(0) if N % 2 == 1: # 真ん中の一つを塗る x = N // 2 + 1 print(1, x) up_ind = x else: # 真ん中の2つを塗る x = N // 2 print(2, x) up_ind = x + 1 while True: t = int(input()) if t < 2: exit(0) k,x = map(int,input().split()) if x < up_ind: print(k, x + up_ind) else: print(k, x - up_ind)