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

#!/usr/bin/env python3
# set vim: fdm=marker sw=4 ts=4 et

from collections import defaultdict
from collections import deque
from sys import stdout

n = int(input())

d = deque()
d.append(0)

seen = [False] * n
seen[0] = True

g = []
for i in range(n):
    g.append([])

while len(d) > 0:
    d_i = d.popleft()
    print('?', d_i + 1)
    stdout.flush()
    a = [int(i) for i in input().split()]

    c = defaultdict(list)
    for i in range(n):
        c[a[i]].append(i)

    b = []
    for k, v in c.items():
        b.append((k, v))
    b.sort()

    for b_i in b:
        k, v = b_i

        if k == 0:
            assert len(v) == 1
            assert v[0] == d_i
            continue

        for v_i in v:
            g[min(d_i, v_i)].append(max(d_i, v_i))
            seen[v_i]

        if len(v) > 1:
            d.extend(v)
            break
        else:
            d_i = v[0]

print('!')
for i in range(n):
    for j in g[i]:
        print(i + 1, j + 1)
