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 math, sys
from itertools import permutations
from collections import defaultdict, Counter, deque 
from heapq import heapify, heappush, heappop

MOD = int(1e9) + 7
INF = float('inf')

def solve():
	n = int(input())

	query = '?'
	ans = '!'

	w = 0
	r = 0

	print(query, 1)
	flush()

	dist = list(map(int, input().split()))

	for i in range(n):
		if dist[i] % 2:
			r += 1
		else:
			w += 1

	consider = 0 if w <= (n + 1) // 2 else 1 

	tree = defaultdict(list)

	for node in range(1, n + 1):
		if dist[node - 1] % 2 != consider:
			continue

		print(query, node)
		flush()

		if node > 1:
			d = list(map(int, input().split()))
		else:
			d = dist

		for to in range(1, n + 1):
			if d[to - 1] == 1:
				tree[node].append(to)
				tree[to].append(node)

	edges = set()
	
	for node in tree:
		for neigh in tree[node]:
			e = sorted([node, neigh])
			edges.add(tuple(e))

	print(ans)
	for u, v in edges:
		print(u, v)


def main():
	ts = 1
	# ts = int(input())
	for t in range(1, ts + 1):
		solve()






def input():
	return sys.stdin.readline().rstrip('\n').strip()

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(sep)
		sys.stdout.write(str(arg))
		first = False 

	sys.stdout.write(end)

def flush():
	sys.stdout.flush()


main()


