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

def readline():
    return map(int, input().split())


def ask(r):
    assert r >= 0
    print('?', r + 1)
    return list(readline())


def say(edges):
    print('!')
    for (a, b) in edges:
        print(a+1, b+1)


def main():
    n = int(input())
    d0 = ask(0)
    cnt = [0, 0]
    for value in d0:
        cnt[value & 1] += 1
    b = 1 if cnt[0] > cnt[1] else 0
    edges = list()
    for (i, value) in enumerate(d0):
        if value & 1 == b:
            di = ask(i) if i != 0 else d0
            edges.extend((i, j) for (j, vj) in enumerate(di) if vj == 1)
    say(edges)


if __name__ == '__main__':
    main()
