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