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

sys.setrecursionlimit(100000)

input = sys.stdin.readline

'''from random import randint

def gen(n):
	V = []
	for i in range(1,n):
		x = randint(0,i-1)
		V.append((i, x))
	p = list(range(n))
	for i in range(n-1):
		x = randint(i+1,n-1)
		p[x], p[i] = p[i], p[x]
	G = [[] for i in range(n)]
	A = []
	for u, v in V:
		A.append(tuple(sorted((p[u]+1,p[v]+1))))
		G[p[u]].append(p[v])
		G[p[v]].append(p[u])
	A.sort()
	return G, A

def make(A):
	G = [[] for i in range(len(A)+1)]
	for u, v in A:
		G[u-1].append(v-1)
		G[v-1].append(u-1)
	return G, A


GG, A = gen(5)
#GG, A = make([(1, 5), (2, 5), (3, 5), (4, 5)])
print(A)'''

def ask(x):
	'''global GG
	d = [None]*len(GG)
	d[x] = 0
	q = [x]
	qi = 0
	while qi < len(q):
		v = q[qi]
		qi += 1
		for u in GG[v]:
			if d[u] is None:
				d[u] = d[v] + 1
				q.append(u)
	print(x,d)
	return d'''
	print('?', x+1)
	sys.stdout.flush()
	return list(map(int, input().split()))

G = None

def rec(a, v):
	#print(a, v)
	global G
	if len(a) == 2:
		G.append((a[0],a[1]))
		return
	D = ask(v)
	best = a[0]
	bd = D[a[0]]
	for i in a:
		if D[i] > bd:
			bd = D[i]
			best = i
	E = ask(best)
	z = dict()
	zz = dict()
	for i in a:
		e = E[i]
		d = D[i]
		if e >= bd and e == bd + d:
			x = 0
			y = e - bd
			#print('me')
		else:
			x = (d-e+bd)//2
			y = (d+e-bd)//2
		#print(i, x, y)
		if (x,y) in z:
			z[(x,y)].append(i)
		else:
			z[(x,y)] = [i]
		if x in zz:
			zz[x].append(i)
		else:
			zz[x] = [i]
	for i in range(bd):
		G.append((z[(i,0)][0], z[(i+1,0)][0]))
	'''for i in range(0,bd):
		if (i,1) in z:
			for j in z[(i,1)]:
				G.append((z[(i,0)][0], j))'''
	for i in zz:
		b = zz[i]
		if len(b) > 1:
			bd = -1
			best = None
			for x in b:
				if E[x] > bd:
					bd = E[x]
					best = x
			rec(b, best)

def solve():
	global G, GG, A
	n = int(input())
	#n = len(GG)
	G = []
	rec(list(range(n)), 0)
	print('!')
	#A1 = []
	for u, v in G:
		#A1.append(tuple(sorted((u+1,v+1))))
		print(u+1, v+1)
	'''A1.sort()
	print(A1==A)
	print(A)
	print(A1)'''
	sys.stdout.flush()

solve()
