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()]

    ans=[]

    if n==1:
        print("!")
        print("1 2")
        continue

    print("? 1")
    temp=[int(x) for x in input().split()]
    odd=0
    even=0
    temp.pop(0)
    visited=[False for x in range(n)]
    visited[0]=True

    for i in range(n-1):
        if temp[i]%2==1:
            odd+=1
        else:
            even+=1
        if temp[i]==1:
            ans.append([1,i+2])

    for i in range(n-1):
        if odd<even and temp[i]%2==1:
            print("? "+str(i+2))
            q=[int(x) for x in input().split()]
            for j in range(n):
                if q[j]==1 and not visited[j]:
                    ans.append([i+2,j+1])
            visited[i]=True
        elif even<=odd and temp[i]%2==0 :
            print("? "+str(i+2))
            q=[int(x) for x in input().split()]
            for j in range(n):
                if q[j]==1 and not visited[j]:
                    ans.append([i+2,j+1])
            visited[i]=True    

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