n = int(input()) if n % 2 == 1: print(1, n // 2) else: print(2, n // 2 - 1) 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 - 1 - k) else: print(2 , n - 1 - k - 1)