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

from collections import defaultdict
from math import ceil
def interact(i):
	print("?",i,flush=True)
	return list(map(int,input().strip().split()))
def f(n):
	mx=ceil(n/2)
	g=set()
	p=[]
	cnt=0
	st=[1]
	g=set()
	s=[[],[]]
	d1=[0]+interact(1)
	for i in range(2,n+1):
		s[d1[i]&1].append(i)
		if d1[i]==1:
			g.add((1,i))
	s=sorted(s,key=lambda s:len(s),reverse=True)
	for x in s[0]:
		d1=[0]+interact(x)
		for i in range(1,n+1):
			if d1[i]==1:
				g.add(tuple(sorted([i,x])))
	print('!')
	for i in g:
		print(*i)




f(int(input()))