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 sys import stdout
from collections import defaultdict as dc
def solve(dec, k, visited):
    visited[k] = True
    a = list(map(int, input(print("? {}".format(k))).split()))
    stdout.flush()
    f = False
    for i in range(n):
        if a[i] == 1:
            dec[k].append(i + 1)
        if a[i] == 3:
            f = True
            if not visited[i + 1]:
                solve(dec, i + 1, visited)
    if not f:
        for i in range(n):
            if a[i] == 2:
                if not visited[i + 1]:
                    solve(dec, i + 1, visited)
    return None


n = int(input())
dec = dc(list)
visited = dc(bool)
solve(dec, 1, visited)
res = []
for i in dec:
    for j in dec[i]:
        res.append([i, j])
print("!")
for j in res:
    print(*j)
stdout.flush()

