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

import sys
input = sys.stdin.readline
n=int(input())
print("?",1)
sys.stdout.flush()
#input()
sys.stdout.flush()
d=list(map(int,input().split()))
sys.stdout.flush()
lv=[0]*(n+1)
od=0
evs=[]
ods=[]
pred=[0]*(n+1)
for i in range(n):
    lv[i+1]=d[i]
    if d[i]==0:
        pred[i+1]=1
    if d[i]%2:
        od+=1
        ods.append(i+1)
    else:
        if i:
            evs.append(i+1)
tod=ods
if od>n/2:
    tod=evs
for x in tod:
    print("?",x)
    sys.stdout.flush()
    #input()
    sys.stdout.flush()
    d=list(map(int,input().split()))
    sys.stdout.flush()
    for i in range(n):
        if d[i]==1:
            if lv[i+1]>lv[x]:
                pred[i+1]=x
            else:
                pred[x]=i+1
print("!")
sys.stdout.flush()
for i in range(2,n+1):
    print(i,pred[i])
    sys.stdout.flush()