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
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd

# sys.setrecursionlimit(100000000)

flush = lambda: stdout.flush()
stdstr = lambda: stdin.readline()
stdint = lambda: int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdmap = lambda: map(int, stdstr().split())
stdarr = lambda: list(map(int, stdstr().split()))

mod = 1000000007


n = stdint()

graph = dd(set)

print("?", 1, flush=True)

x = stdarr()

even = []
odd = []

for j in range(n):
    i = x[j]
    if(i > 0):
        if(i%2 == 0):
            even.append(j+1)
        else:
            odd.append(j+1)

queries = []
if(len(even) < len(odd)):
    queries = even
else:
    queries = odd

for i in queries:
    print("?", i, flush=True)

    x = stdarr()

    for j in range(len(x)):
        if(x[j] == 1):
            graph[i].add(j+1)
            graph[j+1].add(i)



print("!", flush=True)


done = dd(bool)

for i in graph:
    for j in graph[i]:
        if(tuple(sorted([i, j])) not in done):
            print(i, j, flush=True)
            done[tuple(sorted([i, j]))] = True