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
input = sys.stdin.readline

def ask(i):
    print(f"? {i + 1}", flush=True)
    return list(map(int, input().split()))

def main():
    n = int(input())
    ans = []
    dlst = ask(0)
    odd = []
    even = []
    for i, d in enumerate(dlst):
        if d % 2 == 0:
            even.append(i)
        else:
            odd.append(i)
    if len(even) <= len(odd):
        for i, d in enumerate(dlst):
            if d == 1:
                ans.append((1, i + 1))
    else:
        even = odd.copy()
    for i in even:
        if i == 0:
            continue
        dlst = ask(i)
        for j, d in enumerate(dlst):
            if d == 1:
                ans.append((i + 1, j + 1))
    
    print("!")
    for row in ans:
        print(*row)
for _ in range(1):
    main()