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.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            int n=input.nextInt();
            ArrayList<Pair> list=new ArrayList<>();
            ArrayList<Integer> arr[]=new ArrayList[n+1];
            for(int i=0;i<=n;i++)
            {
                arr[i]=new ArrayList<>();
            }
            System.out.println("? 1");
            System.out.flush();
            for(int i=1;i<=n;i++)
            {
                int d=input.nextInt();
                arr[d].add(i);
            }
            int even=0,odd=0;
            for(int i=0;i<=n;i++)
            {
                if(i%2==0)
                {
                    even+=arr[i].size();
                }
                else
                {
                    odd+=arr[i].size();
                }
            }
            int r=n/2;
            r+=n%2;
            if(even<=r)
            {
                for(int i=0;i<arr[1].size();i++)
                {
                    int v=arr[1].get(i);
                    list.add(new Pair(1,v));
                }
                for(int j=2;j<=n;j+=2)
                {
                    if(arr[j].size()>0)
                    {
                        for(int k=0;k<arr[j].size();k++)
                        {
                            int v=arr[j].get(k);
                            System.out.println("? "+v);
                            System.out.flush();
                            for(int i=1;i<=n;i++)
                            {
                                int d=input.nextInt();
                                if(d==1)
                                {
                                    list.add(new Pair(v,i));
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                for(int j=1;j<=n;j+=2)
                {
                    if(arr[j].size()>0)
                    {
                        for(int k=0;k<arr[j].size();k++)
                        {
                            int v=arr[j].get(k);
                            System.out.println("? "+v);
                            System.out.flush();
                            for(int i=1;i<=n;i++)
                            {
                                int d=input.nextInt();
                                if(d==1)
                                {
                                    list.add(new Pair(v,i));
                                }
                            }
                        }
                    }
                }
            }
            out.println("!");
            for(int i=0;i<list.size();i++)
            {
                out.println(list.get(i).a+" "+list.get(i).b);
            }
        }
        out.close();
    }
    public static class Pair
    {
        int a,b;
        Pair(int a,int b)
        {
            this.a=a;
            this.b=b;
        }
    }
    public static long power(long a,long b,long m)
    {
        long res=1;
        while(b>0)
        {
            if(b%2!=0)
            {
                res=(res%m*a%m)%m;
            }
            b=b/2;
            a=(a%m*a%m)%m;
        }
        return res;
    }
    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;
        }
    }
}