import sys

N=int(input())
cond=[0]*(N+2)
cond[0]=1
cond[-1]=1
if N%2==1:
    k=N//2
    print(1,k+1)
    sys.stdout.flush()
    base=k
else:
    k=N//2-1
    print(2,k+1)
    sys.stdout.flush()
    base=k

while True:
    t=int(input())
    if t==0:
        exit()
    elif t==3:
        k,x=map(int,input().split())
        if 1<=x<=base:
            if N%2==1:
                print(k,x+base+1)
                sys.stdout.flush()
            else:
                print(k,x+base+2)
                sys.stdout.flush()
        else:
            if N%2==1:
                print(k,x-base-1)
                sys.stdout.flush()
            else:
                print(k,x-base-2)
                sys.stdout.flush()