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