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.util.*;
import java.io.*;
public class B{
	public static void main(String[] args)
	{
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = fs.nextInt();
		int[][] ed = new int[n-1][2];
		int start = 0;
		System.out.println("? "+1);
		int[] arr = fs.readArray(n);
		List<Integer> even = new ArrayList();
		List<Integer> odd = new ArrayList();
		for(int i=0;i<n;i++)
		{
			if(arr[i]%2 == 0)
			{
				if(arr[i] != 0)even.add(i+1);
			}
			else odd.add(i+1);
		}
		if(even.size()<=odd.size())
		{
			for(int i=0;i<n;i++)
			{
				if(start>=n-1)break;
				if(arr[i] == 1)
				{
					ed[start][0] = 1; ed[start][1] = (i+1);
					start++;
				}
			}
			for(int i:even)
			{
				if(start>=n-1)break;
				System.out.println("? "+i);
				int[] temp = fs.readArray(n);
				for(int ii=0;ii<n;ii++)
				{
					if(start>=n-1)break;
					if(temp[ii] == 1)
					{
						ed[start][0] = i; ed[start][1] = (ii+1);
						start++;
					}
				}
			}
		}
		else
		{
			for(int i:odd)
			{
				if(start>=n-1)break;
				System.out.println("? "+i);
				int[] temp = fs.readArray(n);
				for(int ii=0;ii<n;ii++)
				{
					if(start>=n-1)break;
					if(temp[ii] == 1)
					{
						ed[start][0] = i; ed[start][1] = (ii+1);
						start++;
					}
				}
			}
		}
		out.println("!");
		for(int i=0;i<n-1;i++)
		{
			out.println(ed[i][0]+" "+ed[i][1]);
		}
		out.close();
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static int[] sort(int[] arr)
	{
		List<Integer> temp = new ArrayList();
		for(int i:arr)temp.add(i);
		Collections.sort(temp);
		int start = 0;
		for(int i:temp)arr[start++]=i;
		return arr;
	}
	public static String rev(String str)
	{
		char[] arr = str.toCharArray();
		char[] ret = new char[arr.length];
		int start = arr.length-1;
		for(char i:arr)ret[start--] = i;
		String ret1 = "";
		for(char ch:ret)ret1+=ch;
		return ret1;
//		return ret;
	}
}