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

n=int(input())
a=[1]*n
b=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    if a[i]:
        a[i]=0
        print('?',i+1)
        d=list(map(int,input().split()))
        e=-1
        for j in range(n):
            if d[j]==1:
                if e==-1:
                    e=j
                else:
                    e=-2
                b[i][j]=1
                b[j][i]=1
                a[j]=0
        f=2
        while e>=0:
            e1=-1
            for j in range(n):
                if d[j]==f:
                    if e1==-1:
                        e1=j
                    else:
                        e1=-2
                    b[j][e]=1
                    b[e][j]=1
                    a[j]=0
            e=e1
            f+=1
print('!')
for i in range(n):
    for j in range(i+1,n):
        if b[i][j]:
            print(i+1,j+1)