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

# cook your dish here
n=int(input())
visited=[0]*n
arr=[]
arr.append(1)
d={}
edges=0
for i in range(n):
    d[i]=[0]*n
while(len(arr)>0 and edges<n-1):
    temp=arr[len(arr)-1]
    arr.pop()
    print("?",temp,flush=True)
    l=[int(x) for x in input().split()]
    dist=[]
    for i in range(n):
        dist.append([])
    for i in range(n):
        dist[l[i]].append(i)
    for i in range(n-1):
        if len(dist[i])==1:
            for x in dist[i+1]:
                if (d[dist[i][0]][x]==0):
                    d[dist[i][0]][x]=1
                    d[x][dist[i][0]]=2
                    edges+=1
                    arr.append(x+1)
print("!")
for i in range(n):
    for j in range(len(d[i])):
        if (d[i][j]==1):
            print(i+1,j+1)
