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 java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer;
import java.util.*;
public class codeforcesC{
   static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
 
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
 
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
 
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
 
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
 
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
 
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
   } 
   static int f1(int[] a, int[] b){
    return a[0]-b[0];
    }
    public static boolean flag[];
    public static int n;
    public static FastReader sc;
    public static StringBuilder sb;
   public static void main(String args[]){
       sc=new FastReader();
       n=sc.nextInt();
       sb=new StringBuilder();
      // ? 1
      // a1 a2 a3 a4
      // list.add(true)
       flag=new boolean[n+1];
      for(int i=1;i<n+1;i++){flag[i]=false;}
      funcn(1);
      System.out.println("!");
      System.out.println(sb.toString());
      System.out.flush();
   }
   public static void funcn(int pos){
    System.out.println("? "+pos);
       flag[pos]=true;
      List<Integer> l1=new ArrayList<>();
      List<Integer> l2=new ArrayList<>();
      for(int i=1;i<n+1;i++){
          int a=sc.nextInt();
          if(!flag[i]){
              l1.add(i);l2.add(a);
            }
        }
        int len=l1.size();
       int ar[][]=new int[len][2];
       for(int i=0;i<len;i++){ar[i][0]=l2.get(i);ar[i][1]=l1.get(i);}
       Arrays.sort(ar,(z,s)->f1(z,s));
       int count=0;
       int dist=1;
       int u=pos;
       /*
       for(int i=0;i<len;i++){System.out.print(ar[i][0]+" ");}
       System.out.println();
       for(int i=0;i<len;i++){System.out.print(ar[i][1]+" ");}*/
       System.out.println();
       for(int i=0;i<len;i++){
           if(ar[i][0]==dist){
               sb.append(u+" "+ar[i][1]);
               sb.append("\n");
               flag[u]=true;
               count++;
            }
            else{
              if(count==1){
               u=ar[i-1][1];
               flag[u]=true;
               sb.append(u+" "+ar[i][1]);
               sb.append("\n");
               count=1;
               dist++;
             }
             else{
                  //run funcn for count-1 times
                  for(int j=i-count;j<i;j++){
                     funcn(ar[j][1]);
                    }
                }
            }
        }
    
    }
}