5
5 3
2 4
3 1
4 5
 4
2 4
3 2
2 1
 5
5 3
2 4
3 1
4 5
 2
1 2
 4
3 4
2 3
3 1
 10
8 10
2 9
7 8
4 1
7 3
4 7
2 5
2 4
4 6
 5
3 4
3 2
3 1
1 5
 3
1 2
2 3
 5
1 2
1 3
1 4
1 5

1 2
2 3
2 4
 1 3
2 4
3 5
4 5
 1 2
 1 3
2 3
3 4
 1 4
2 4
2 5
2 9
3 7
4 6
4 7
7 8
8 10
 1 3
1 5
2 3
3 4
 1 2
2 3
 1 2
1 3
1 4
1 5

from math import ceil
from sys import stdout
def mtree(nd,c,li,ar,n):
    if (c[0]>=ceil(n/2))or(c[1]==(n-1)): return

    li[nd]=1

    print("?",nd)
    lr=list(map(int,input().split()))
    stdout.flush()
    c[0]+=1
    a2=[]

    for i in range(n):
        x=lr[i]
        if x==1:
            if li[i+1]==0:
                ar[nd].append(i+1)
                li[i+1]=1
                c[1]+=1
            elif i!=0:
                ar[i+1].append(nd)
                c[1]+=1
        elif x==2:
            if li[i+1]==0:
                a2.append(i+1)

    for y in a2:
        mtree(y, c, li, ar, n)
    return












n=int(input())
ar=[[] for i in range(n+1)]
print("?",1)
lii=list(map(int,input().split()))
e=0
li=[0]*(n+1)
li[1]=1
for i in range(n):
    if lii[i]%2==0:
        e+=1
    else:
        if lii[i]==1:
            ar[1].append(i+1)

            li[i+1]=1
c=[1,len(ar[1])]
if e>(n//2+1):
    mtree(ar[1][0],c,li,ar,n)
else:
    mtree(lii.index(2)+1, c, li, ar, n)

print('!')
for i in range(1,n+1):
    ll=ar[i]
    for j in ll: print(i,j)
