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
input = sys.stdin.readline
flush = sys.stdout.flush

def query(x):
    print('?', x)
    flush()
    return list(map(int, input().split()))

n = int(input())
ans = set()
A = query(1)
X, Y = [], []
for i, a in enumerate(A, 1):
    if not a % 2: X.append(i)
    else: Y.append(i)
if len(X) > len(Y): X, Y = Y, X
for x in X:
    if x != 1: B = query(x)
    else: B = A
    for i, b in enumerate(B, 1):
        if b == 1:
            ans.add((x, i))
print('!')
flush()
for a in ans:
    print(*a)
    flush()
