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

import sys
import collections
import queue

sys.stdout.flush()
n = int(input())

q = queue.Queue()
q.put(1)
d = {}
vis = set()


def link(a, b):
    d.setdefault(a, set())
    d.setdefault(b, set())
    d[a].add(b)
    d[b].add(a)


while len(d) != n:
    print(d)
    if q.empty():
        for i in range(1, n + 1):
            if i not in d and i not in vis:
                q.put(i)
    node = q.get()
    vis.add(node)
    print('? ' + str(node))
    sys.stdout.flush()
    ret = [int(i) for i in input().split()]
    c = collections.Counter(ret)
    dd = {}
    for i, v in enumerate(ret):
        dd[v] = i + 1
    now = 1
    pre = node
    while c[now] == 1 and now in dd:
        link(pre, dd[now])
        pre = dd[now]
        now += 1
    if now in dd:
        q.put(dd[now])

ret = []
for node, nxts in d.items():
    for nxt in nxts:
        if node < nxt:
            ret.append(str(node) + ' ' + str(nxt))
print('\n'.join(ret))
