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
from collections import deque
def get(i):
    print("?", i+1)
    return list(map(int, input().split()))
n = int(input())
e = set()
c = 0
z = get(0)
odd = 0
even = 0
for i, x in enumerate(z):
    if x == 0:
        continue
    if x & 1:
        odd += 1
    else:
        even += 1
    if x == 1:
        e.add((0, i))
if odd < even:
    for i, x in enumerate(z):
        if (x & 1) == 0:
            continue
        z2 = get(i)
        for j, y in enumerate(z2):
            if y == 1:
                e_ = (min(i, j), max(i, j))
                e.add(e_)
else:
    for i, x in enumerate(z):
        if (x & 1) == 1 or i == 0:
            continue
        z2 = get(i)
        for j, y in enumerate(z2):
            if y == 1:
                e_ = (min(i, j), max(i, j))
                e.add(e_)
print("!")
for E in e:
    print(E[0] + 1, E[1] + 1)
sys.stdout.flush()
