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
from sys import stdout
import io, os

# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
# input = sys.stdin.buffer.readline
input = lambda: sys.stdin.readline().strip()
P = lambda: list(map(int, input().split()))
from math import factorial as f, gcd
from collections import deque, defaultdict as dd, Counter as C
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, merge
from random import randint, choice, sample
import time
mod = 10**9+7
a = ord('a')


start = time.time()
def fast_exp(x, exp):
    ans = 1
    base = x
    while exp:
        if exp & 1:
            ans *= base
        base *= base
        base %= mod
        ans %= mod
        exp >>= 1
    return ans

def countBits(n):
    count = 0
    while n:
        count += n & 1
        n >>= 1
    return count

def submasks(n):
    #this is cool
    #https://cp-algorithms.com/algebra/all-submasks.html
    org = n
    while n:
        yield n
        n = (n-1) & org


def query(i):
    print('?', i+1)
    stdout.flush()
    return P()

def solve():
    n = int(input())
    mat = [[0]*n for _ in range(n)]
    start = query(0)
    for i, x in enumerate(start):
        if x == 1:
            mat[i][0] = 1
            mat[0][i] = 1

    odd = sum([i%2 for i in start[1:]])
    even = n-1-odd
    if odd < even:
        for i, x in enumerate(start):
            if x % 2:
                temp = query(i)
                for j, y in enumerate(temp):
                    if y == 1:
                        mat[i][j] = 1
                        mat[j][i] = 1
    else:
        for i, x in enumerate(start):
            if x % 2 == 0 and x:
                temp = query(i)
                for j, y in enumerate(temp):
                    if y == 1:
                        mat[i][j] = 1
                        mat[j][i] = 1
    print("!")
    for i in range(n):
        for j in range(i+1, n):
            if mat[i][j]:
                print(i+1, j+1)
    
        










    






# tc = int(input())
# for t in range(1, tc+1):
#     solve()

solve()
# print(time.time()-start)


