import sys

n = int(input())
if n%2:
    print(1,(n+1)//2)
    c = (n+1)//2
    sys.stdout.flush()
else:
    print(2,n//2)
    c = n//2
    sys.stdout.flush()

while True:
    t = int(input())
    if t == 0:
        exit()
    k,x = map(int,input().split())
    if k == 1:
        print(1,1+n-x)
        sys.stdout.flush()
    else:
        print(2,n-x)
        sys.stdout.flush()