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

from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat, permutations
import math
import heapq


def inp(force_list=False):
    re = map(int, raw_input().split())
    if len(re) == 1 and not force_list:
        return re[0]
    return re

def inst():
    return raw_input().strip()

def gcd(x, y):
   while(y):
       x, y = y, x % y
   return x

MOD = 998244353

def qmod(a, b, mod=MOD):
    res = 1
    while b:
        if b&1:
            res = (res*a)%mod
        b >>= 1
        a = (a*a)%mod
        # print b
    return res

def inv(a):
    return qmod(a, MOD-2)

def my_main():
    kase = 1#inp()
    pans = []
    def query(num):
        print '?', num
        stdout.flush()
        return inp()
    for _ in range(kase):
        n = inp()
        st = [0] * (n+1)
        G = [[] for i in range(2005)]
        for i in range(1, n):
            if st[i]:
                continue
            da = query(i)
            mp = [[] for i in range(n)]

            for i in range(n):
                mp[da[i]].append(i+1)
            if len(mp[1])==1:
                mp1 = mp[1][0]
                G[i].append(mp1)
                # print 'xxxx', i, mp1
                pans.append("%s %s" % (i, mp1))
                st[mp1] = 1
                for j in mp[2]:
                    st[j] = 1
                    G[mp1].append(j)
                    # print '???', mp1, j
                    pans.append("%s %s" % (j, mp1))
            else:
                for j in mp[1]:
                    G[i].append(j)
                    st[j] = 1
                    # print 'fff'
                    pans.append("%s %s" % (j, i))
        print '!'
        print '\n'.join(pans)



my_main()
