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.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.List;
 import java.util.*;
 public class realfast implements Runnable 
  {
    private static final int INF = (int) 1e9;
    long in= 1000000007;
    long fac[]= new long[1000001];
    long inv[]=new long[1000001];
    public  void solve() throws IOException 
    {

        //int t = readInt();
       Scanner in = new Scanner(System.in);

       int n = in.nextInt();
       ArrayList<Integer> arr[]=new ArrayList[n+1];
       for(int i=1;i<=n;i++)
        arr[i]= new ArrayList<Integer>();

       ArrayList<Integer> even= new ArrayList<Integer>();
       ArrayList<Integer> odd = new ArrayList<Integer>();

       System.out.println("? 1");
       System.out.flush();
       int dist[]=new int[n+1];

       for(int i=1;i<=n;i++)
       {
         dist[i]= in.nextInt();
       }

       for(int i=1;i<=n;i++)
       {
          if(dist[i]%2==0)
          {
             even.add(i);
          }
          else
            odd.add(i);
          if(dist[i]==1)
            arr[1].add(i);
       }


       if(odd.size()<even.size())
       {
          for(int j=0;j<odd.size();j++)
          {
             int c = odd.get(j);
             System.out.println("? "+c);
             System.out.flush();
             for(int i=1;i<=n;i++)
             {
              dist[i]= in.nextInt();
             }
             for(int i=2;i<=n;i++)
             {
                if(dist[i]==1)
                {
                    if(i<c)
                        arr[i].add(c);
                    else
                        arr[c].add(i);
                }
             }

          }
       }
       else
       {

          for(int j=0;j<even.size();j++)
          {
             int c = even.get(j);
             if(c==1)
                continue;
             System.out.println("? "+c);
             System.out.flush();
             for(int i=1;i<=n;i++)
             {
              dist[i]= in.nextInt();
             }
             for(int i=2;i<=n;i++)
             {
                if(dist[i]==1)
                {
                    if(i<c)
                        arr[i].add(c);
                    else
                        arr[c].add(i);
                }
             }

          }

       }

       System.out.println("! ");

       for(int i=1;i<=n;i++)
       {
        for(int j =0;j<arr[i].size();j++)
        {
             int k = arr[i].get(j);
             System.out.println(i+" "+k);
        }
       }

       



         



        



    }
    public int find(int parent[] , int i )
    {
        if(parent[i]==i)
            return parent[i];
        parent[i]= find(parent,parent[i]);
        return parent[i];
    }
    public void union(int parent[] , int u , int v)
    {
        int par1 = find(parent,u);
        int par2= find(parent,v);
        if(par1==par2)
            return ;
        parent[par1]=par2;

    }
    
    public int value (int seg[], int left , int right ,int index, int l, int r)
    {
            
            if(left>right)
            {
              return -100000000;
            }
            if(right<l||left>r)
                return -100000000;
            if(left>=l&&right<=r)
                return seg[index];
            int mid = left+(right-left)/2;
            int val = value(seg,left,mid,2*index+1,l,r);
            int val2 = value(seg,mid+1,right,2*index+2,l,r);
            return Math.max(val,val2);

    }
   
    public int gcd(int a , int b )
    {
      if(a<b)
      {
        int t =a;
        a=b;
        b=t;
      }
      if(a%b==0)
        return b ;
      return gcd(b,a%b);
    }
    public long pow(long n , long p,long m)
    {
         if(p==0)
            return 1;
        long val = pow(n,p/2,m);;
        val= (val*val)%m;
        if(p%2==0)
            return val;
        else
            return (val*n)%m;
    }
    
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static void main(String[] args) {
        new Thread(null, new realfast(), "", 128 * (1L << 20)).start();
    }
 
    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    private PrintWriter out;
 
    @Override
    public void run() {
        try {
            if (ONLINE_JUDGE || !new File("input.txt").exists()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                reader = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            solve();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // nothing
            }
            out.close();
        }
    }
 
    private String readString() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
 
    @SuppressWarnings("unused")
    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }
 
    @SuppressWarnings("unused")
    private long readLong() throws IOException {
        return Long.parseLong(readString());
    }
 
    @SuppressWarnings("unused")
    private double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }
}
class edge implements Comparable<edge>{
    int u ;
    int v;
    
    edge(int u, int v)
    {
       this.u=u;
       this.v=v;
    }
    public int compareTo(edge e)
    {
        return this.v-e.v;
    }
}