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 collections import defaultdict
import math
import sys




def query(u):
    print(f"? {u}")
    sys.stdin.flush()
    val=list(map(int,input().split()))
    return val







n=int(input())
dist=query(1)

odd=[]
even=[]
edges=[]
depth=[float("inf") for i in range(n+1)]
depth[1]=0
ans=[]
for j in range(1,n):
    if dist[j]==1:
        ans.append([1,j+1])
    depth[j+1]=dist[j]

    if dist[j]%2:
        odd.append([dist[j],j+1])
    else:
        even.append([dist[j], j + 1])


if len(odd)<len(even):
    odd.sort()
    for j in odd:
        dis,u=j
        val=query(u)
        for j in range(n):
            if val[j]==1:
                edges.append([u,j+1])

else:
    even.sort()
    for j in even:
        dis,u=j
        val=query(u)
        for j in range(n):
            if val[j]==1:
                edges.append([u,j+1])

d=dict()
print("!")
sys.stdout.flush()
for j in edges:
    if (j[0],j[1]) not in d.keys():
        print(*j)
        sys.stdout.flush()

    d[(j[0],j[1])]=1
    d[(j[1],j[0])]=1



















