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

#t=int(input())
t=1
for i in range(t):
    #n,m=map(int,input().split())
    n=int(input())
    #a=[int(x) for x in input().split()]
    #b=[int(x) for x in input().split()]
    
    visited=[False for x in range(n)]
    visited[0]=True
    ans=[]
    ans_length=0

    if n==1:
        print("!")
        print("1 2")
        continue
    query=1
    while ans_length<n-1:
        visited[query-1]=True
        print("? "+str(query))
        temp=[int(x) for x in input().split()]
        count=[n for x in range(n+1)]
        values=[[] for x in range(n+1)]

        for i in range(n):
            count[temp[i]]=(count[temp[i]]+1)%n
            if not visited[i]:
                values[temp[i]].append(i)
            if temp[i]==1 and not visited[i]:
                ans.append([query,i+1])
                ans_length+=1
        arr=[]
        for i in range(1,n):
            arr.append([count[i],i])
        arr.sort()
        flag=False
        for i in arr:
            for j in values[i[1]]:
                if not visited[j]:
                    query=j+1
                    flag=True
                    break
            if flag:
                break


    print("!")
    for i in ans:
        print(*i)
                