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

N = int(input())
if N == 2:
    print("!")
    print(1, 2)
    exit()

ANS = set()
def ha(i, j):
    if i > j:
        i, j = j, i
    return (i << 20) + j

def addans(i, j):
    if i == j: return
    ANS.add(ha(i, j))

def ask(i):
    print("?", i + 1)
    L = [int(a) for a in input().split()]
    for j, a in enumerate(L):
        if a == 1:
            addans(i, j)
    return L

A = ask(0)
e = 0
o = 0
E = []
O = []
for i, a in enumerate(A):
    if i == 0: continue
    if a % 2:
        o += 1
        O.append(i)
    else:
        e += 1
        E.append(i)

if o >= e:
    for i in E:
        ask(i)
else:
    for i in O:
        ask(i)

print("!")
mmm = (1 << 20) - 1
for ij in ANS:
    i = ij >> 20
    j = ij & mmm
    print(i + 1, j + 1)
