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 math
n=int(input())
i=0
s=set({1})
q=[1]
arr=set()
while q and i+1<=math.ceil(n/2):
    tmp=q.pop(-1)
    print(f'? {tmp}')
    b=list(map(int,input().split()))
    p=b.count(1)
    if p==1:
        ind1=b.index(1)
        arr.add((max(tmp,ind1+1),min(tmp,ind1+1)))
        for x in range(len(b)):
            if b[x]==2:
                s.add(x+1)
                arr.add((max(ind1+1,x+1),min(ind1+1,x+1)))
            elif b[x]==3:
                s.add(x+1)
                q.append(x+1)
    else:
        for x in range(len(b)):
            if b[x]==1:
                arr.add((max(tmp,x+1),min(tmp,x+1)))
            elif b[x]==2 and x+1 not in s:
                q.insert(0,x+1)
                s.add(x+1)
    i+=1
print('!')
for x in arr:
    print(x[0],x[1])