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

n = int(input())
if n == 2:
    print("!")
    print(1, 2)
else:   
    p = [-1] * n
    cnt = 0
    print("? 1")
    d0 = list(map(int, input().split()))
    a = sorted([(d0[i], i) for i in range(n)], reverse=True)
    for i in range(n - 1):
        v = a[i][1]
        if p[v] == -1:
            print("?", v + 1)
            d = list(map(int, input().split()))
            b = sorted([(d[i], i) for i in range(n)])
            last = b[1][1]
            p[v] = last
            cnt += 1
            j = 2
            while j < n and b[j][0] == 2:
                u = b[j][1]
                if d0[u] == d0[v] - 2:
                    if p[last] == -1:
                        p[last] = u
                        cnt += 1
                        last = u
                elif p[u] == -1:
                    p[u] = p[v]
                    cnt += 1
                j += 1
            while j < n and b[j][0] == 3:
                u = b[j][1]
                if d0[u] == d0[v] - 3:
                    if p[last] == -1:
                        p[last] = u
                        cnt += 1
                        last = u
                elif p[u] == -1:
                    p[u] = p[p[v]]
                    cnt += 1
                j += 1
            while j < n and a[i][0] >= b[j][0]:
                u = b[j][1]
                if d0[u] == d0[v] - b[j][0]:
                    p[last] = u
                    cnt += 1
                    last = u   
                j += 1
        #print(p)
        if cnt == n - 1:
            print("!")
            for i in range(n):
                if p[i] != -1:
                    print(i + 1, p[i] + 1)
            break