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 os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right

mod = 10 ** 9 + 7



def solve(num):
    print('?',num)
    sys.stdout.flush()
    a=list(map(int,input().split()))
    sys.stdout.flush()
    d=dict()
    z=0
    for i,v  in enumerate(a):
        d[v]=d.get(v,[])
        d[v].append(i+1)
        z=max(z,v)
    #print(d)
    for i in range(z):
        if len(d[i])==1:
            t=d[i][0]
            if t in s:
                s.remove(t)
            for j in d[i+1]:
                ans[t].add(j)
                if j in s:
                    s.remove(j)


n=int(input())
sys.stdout.flush()
ans=[set() for _ in range(n+1)]
s=set()
for i in range(1,n+1):
    s.add(i)
for i in range(1,n+1):
    if i in s:
        solve(i)
    if i in s:
        s.remove(i)
ck=set()
for i in range(1,n+1):
    ck.add(i)
#print(ans)
print("!")
sys.stdout.flush()
for i in range(1,n+1):
    for j in ans[i]:
        if (i,j) in ck or (j,i) in ck:
            continue
        print(i,j)
        sys.stdout.flush()
        ck.add((i,j))
sys.stdout.flush()