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 deque

n = int(input())
status = [0]*n
status[0] = 2
ask = deque([0])
res = []
while ask and len(res)<n-1:
    u = ask.popleft()
    print('?', u+1, flush=True)
    arr = list(map(int, input().split()))
    pa = [v for v,d in enumerate(arr) if d==1 and status[v]==1]
    ch = [v for v,d in enumerate(arr) if d==1 and status[v]==0]
    two = [v for v,d in enumerate(arr) if d==2 and status[v]!=2]
    for v in ch:
        status[v] = 1
        res.append([u,v])
    if pa:
        res.append([u,pa[0]])
    if len(ch)==1:
        v = ch[0]
        status[v] = 2
        for w in two:
            res.append([v,w])
    ask.extend(two)
print('!')
for u, v in res:
    print(u+1, v+1)
