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

n=int(input())
E=[]
E1=[set() for i in range(n+1)]

USE=[0]*(n+1)

for i in range(1,n+1):
    if USE[i]==0:
        print("?",i,flush=True)
        X=list(map(int,input().split()))

        O=[]
        T=[]

        for j in range(n):
            if X[j]==1:
                O.append(j+1)
                USE[j+1]=1
            elif X[j]==2:
                T.append(j+1)

        for o in O:
            E.append((i,o))

            for t in T:
                if (t in E1[o]) or (o in E1[t]):
                    E.append((o,t))
                    USE[o]=1
                    USE[t]=1
                else:
                    E1[o].add(t)

print("!",flush=True)
for x,y in E:
    print(x,y,flush=True)

        

        
        

