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

n = int(input())
assigned = [False]*(1+n)
Edges = set()

def add(x,y):
    Edges.add((min(x,y), max(x,y)))

print("?",1)
sys.stdout.flush()

d = [0] + list(map(int,input().split()))
EVEN = set()
ODD = set()

assigned[1] = True
for y in range(1,n+1):
    if d[y] == 1:
        add(1,y)

for x in range(1,n+1):
    if d[x] % 2:
        ODD.add(x)
    else:
        EVEN.add(x)

A = EVEN if len(EVEN) < len(ODD) else ODD    

for x in A:
    if assigned[x]: continue
    assigned[x] = True

    print("?",x)
    sys.stdout.flush()

    dx = [0] + list(map(int,input().split()))
    for y in range(1,n+1):
        if dx[y] == 1:
            assigned[y] = True
            add(x,y)

print("!")
for x,y in Edges: print(x,y)
exit()
