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 io, os
input = sys.stdin.buffer.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n = int(input())

used = set()
edge = set()
for i in range(n):
    if i in used:
        continue
    #print(used)
    print('?', i+1, flush=True)
    D = list(map(int, input().split()))
    ind = 0
    temp = []
    for j, d in enumerate(D):
        if d == 1:
            v = min(i, j)
            u = max(i, j)
            used.add(j)
            edge.add((v+1, u+1))
            ind += 1
            temp.append(j)
    if ind == 1:
        k = temp[0]
        for j, d in enumerate(D):
            if d == 2:
                v = min(k, j)
                u = max(k, j)
                edge.add((v+1, u+1))
                used.add(j)

print('!', flush=True)
for u, v in edge:
    print(u, v, flush=True)
