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
from sys import stdin, stdout
input, print = stdin.readline, stdout.write
from collections import OrderedDict, defaultdict

adj = defaultdict(list)
vis = defaultdict(int)
inq = defaultdict(int)
n = int(input())
unv = n

def qry(r):
    global adj, vis, q, n, unv
    print("? ")
    print(str(r+1))
    print('\n')
    stdout.flush()
    d = [*map(int, input().split())]
    
    a = []
    b = []
    c = []
    for i in range(len(d)):
        if d[i] == 1 and vis[i] == 0:
            a.append(i)
        if d[i] == 2 and vis[i] == 0:
            b.append(i)
        if d[i] == 3 and vis[i] == 0:
            c.append(i)

    for x in a:
        adj[r].append(x)
        adj[x].append(r)
        vis[x] = 1
        unv -= 1
    
    # if len(a) == 1:
        for x in b:
            # adj[a[0]].append(x)
            # adj[x].append(a[0])
            # vis[x] = 1
            # unv -= 1
            # if len(b) != 1:
                q.append(x)

        # if len(b) == 1:
            # for x in c:
                # adj[b[0]].append(x)
                # adj[x].append(b[0])
                # vis[x] = 1
                # unv -= 1
                # q.append(x)


q = [0]
while len(q) > 0 and unv > 0:
    v = q.pop(0)
    vis[v] = 1
    unv -= 1
    qry(v)

print('!\n')
done = defaultdict(set)
for i in range(n):
    for x in adj[i]:
        if i in done[x]:
            continue
        print(str(i + 1))
        print(' ')
        print(str(x + 1))
        print('\n')
        done[x].add(i)
        done[i].add(x)
stdout.flush()

# for x in adj:
#     print(str(adj))
#     print('\n')
# print(str(adj))
# print('\n')
# print(str(vis))