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

def answer():

    print('?',1)

    d=list(map(int,input().split()))

    edges=[]
    even,odd=[],[]
    for i in range(len(d)):
        if(d[i] & 1):
            odd.append(i+1)
        else:
            even.append(i+1)

        if(d[i]==1):edges.append([1,i + 1])

    if(len(even) < len(odd)):

        for i in even:
            print('?',i)

            d=list(map(int,input().split()))
            for j in range(len(d)):
                
                if(j+1!=1 and d[j]==1):
                    edges.append([i,j+1])
    else:
        
        for i in odd:
            if(i==1):continue
            
            print('?',i)

            d=list(map(int,input().split()))
            for j in range(len(d)):

                if(j+1!=1 and d[j]==1):
                    edges.append([i,j+1])

    print('!')
    for x in edges:print(*x)
                    

n=int(input())

answer()
