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

# cook your code here
from sys import stdin ,stdout
def solve(x,n):
    print "?",x
    stdout.flush()
    v.add(x)
    one=[]
    two=[]
    l=map(int,raw_input().split())
    ind=-1
    for i in xrange(n):
        if l[i]==1:
            ind=i+1
            one.append(i+1)
        if l[i]==2:
            two.append(i+1)
    if len(one)==1:
        a,b=min(ind,x),max(ind,x)
        s.add((a,b))
        t=[]
        for i in range(n):
            if l[i]==2:
                a,b=min(ind,i+1),max(ind,i+1)
                s.add((a,b))
                if b not in v:
                    t.append(b)
                if a not in v:
                    t.append(a)
        for i in t:
            if len(s)<n-1:
                solve(i,n)
    else:
        t=[]
        for i in range(n):
            if l[i]==1:
                a,b=min(i+1,x),max(i+1,x)
                if (a,b) not in s:
                    s.add((a,b))
                    if b not in v:
                        t.append(b)
                    if a not in v:
                        t.append(a)
        for i in t:
            if len(s)<n-1 and i not in v:
                solve(i,n)
                    

n=input()
s=set()
v=set()
solve(1,n)
print "!"
for x in s:
    print x[0],x[1]