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

# Author : nitish420 --------------------------------------------------------------------
import os
import sys
from io import BytesIO, IOBase


def main():
	n=int(input())
	tree=[]

	odd=[]
	even=[]
	print("? 1",flush=True)
	arr=list(map(int,input().split()))

	for i,item in enumerate(arr):
		if item&1:
			odd.append(i+1)
		else:
			even.append(i+1)
	# print(odd)
	# print(even)
	if len(odd)<len(even):
		for i in odd:
			print(f'? {i}',flush=True)
			arr=list(map(int,input().split()))
			for j,item in enumerate(arr):
				if item==1:
					tree.append((i,j+1))
	else:
		for i in even:
			if i!=1:
				print(f'? {i}',flush=True)
				arr=list(map(int,input().split()))
			for j,item in enumerate(arr):
				if item==1:
					tree.append((i,j+1))
	
	# output
	print("!")
	for item in tree:
		print(*item)
	
'''
7

1:
0 1 1 2 3 3 4
2:
1 0 2 1 2 2 3
3:
1 2 0 3 4 4 5
5:
3 2 4 1 0 2 1
6:
3 2 4 1 2 0 3

7
? 1
0 1 1 2 3 3 4
? 4
2 1 3 0 1 1 2
? 7
4 3 5 2 1 3 0

'''


#----------------------------------------------------------------------------------------


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda: self.buffer.read().decode('ascii')
		self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')


# endregion

if __name__ == '__main__':
	main()