N = int(input()) if N & 1: n = N // 2 + 1 print(1,n) else: n = N // 2 print(2,n) while True: t = input() if t == 0: break k,x = map(int,input().split()) if k == 1: print(1,N + 1 - x) else: print(2,N + 1 - x - 1)