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
import sys
from io import BytesIO, IOBase
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")
##########################################################
from collections import Counter, defaultdict
import math
sys.setrecursionlimit(10**3)
def dfs(s):
    coming_val=arr[s]
    vis[s]=1
    ind=ls.index(coming_val)
    if vis[ind]==0:
        dfs(ind)





for _ in range(1):
    n=int(input())
    #s=input()
    #a,b=map(int, input().split())
    #arr =list(map(int, input().split()))
    #ls= list(map(int, input().split()))
    print("?", 1)
    sys.stdout.flush()
    arr = list(map(int, input().split()))
    g=[set() for i in range(1+n)]
    child=1
    cnt=0
    cc=1
    for j in range(n):
        if arr[j]==1:
            g[1].add(j+1)
            cnt+=1
            child=j+1
    dis=2
    next=-1
    while cnt==1 and dis<2005:
        cnt=0
        for j in range(n):
            if arr[j]==dis:
                g[child].add(j+1)
                cnt+=1
                next=j+1
        if cnt>0:
            child=next
        dis+=1
    print(g)
    while cc<(n+1)//2:
        print("?",child)
        sys.stdout.flush()
        arr = list(map(int, input().split()))
        dis = 1
        cnt=1
        next=-1
        while cnt == 1 and dis < 2005:
            cnt = 0
            for j in range(n):
                if arr[j] == dis:
                    g[child].add(j + 1)
                    cnt += 1
                    next = j + 1
            if cnt>0:
                child=next
            dis += 1
        cc+=1


    print("!")
    print(g)
    vis=[0]*(n+2)

    for  i in range(1,n+1):
        for j in g[i]:
            if vis[j]==0:
                print(i, j)

        vis[i]=1

















