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

#!/usr/bin/env python3
def f(n):
    if n == 2:
        print('!')
        print('1 2')
        return
    edges = set()
    print('? 1')
    xs = [int(x) for x in input().split()]
    for i, x in enumerate(xs):
        if x == 1:
            edges.add((1, i + 1))
    parity = [0, 0]
    for x in xs:
        if x > 0:
            parity[x % 2] += 1
    p = 1 if parity[0] > parity[1] else 0
    for i, x in enumerate(xs):
        if i > 0 and x % 2 == p:
            print('?', i+1)
            ys = [int(y) for y in input().split()]
            for j, y in enumerate(ys):
                if y == 1:
                    if i < j:
                        edges.add((i+1, j+1))
                    else:
                        edges.add((j+1, i+1))
    print('!')
    for x, y in edges:
        print(x, y)


f(int(input()))
