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

from sys import stdin,stdout
input = stdin.readline
 
def output(a,b):
    stdout.write("{} {}\n".format(a,b))
    
    
for _ in range(1):
    
    n = int(input())
    visited = [False for i in range(n+1)]
    parent = [-1 for i in range(n+1)]
    
    for node in range(1,n+1):
        if(visited[node] == True):
            continue
        output("?",node)
        stdout.flush()
        arr = list(map(int,input().split()))
        stack = []
        for index,value in enumerate(arr):
            if(value == 1 and index+1 != parent[node]):
                stack.append(index+1)
                parent[index+1] = node
                visited[index+1] = True
        level = 2
        while(len(stack) == 1):
            node = stack.pop()
            for index,value in enumerate(arr):
                if(value == level):
                    visited[index+1] = True
                    parent[index+1] = node
                    stack.append(index+1)
            level += 1
    
    edges = []
    for i in range(1,n+1):
        if(parent[i] != -1):
            edges.append((i,parent[i]))
    
    stdout.write("!\n")
    for u,v in edges:
        output(u,v)