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())
adj = [set() for _ in range(n)]
visited = [False] * n
visited[0] = True
q = deque([0])
while q:
    u = q.popleft()
    print('?', u+1, flush=True)
    d = list(map(int, input().split()))
    ones = []
    twos = []
    for v in range(n):
        if d[v] == 1:
            ones.append(v)
        elif d[v] == 2:
            twos.append(v)
    for v in ones:
        adj[u].add(v)
        adj[v].add(u)
    unvOnes = []
    unvTwos = []
    for v in ones:
        if not visited[v]:
            unvOnes.append(v)
    for v in twos:
        if not visited[v]:
            unvTwos.append(v)
    if len(ones) < len(unvTwos):
        for v in unvOnes:
            q.append(v)
            visited[v] = True
    else:
        for v in unvTwos:
            q.append(v)
            visited[v] = True
    
print('!', flush=True)
for u in range(n):
    for v in adj[u]:
        print(u+1, v+1, flush=True)
        adj[v].remove(u)