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

#include <bits/stdc++.h>
using namespace std;
#define LOCAL
typedef long long ll;
typedef unsigned long long ull;
const int maxn= 2007;
const int mod=1e9+7;
const double eps=1e-8;
const ll LINF=9223372036854775807;
const int INF=2147483647;
void init()
{
#ifdef LOCAL
    freopen ("data.txt", "r", stdin);
    freopen ("out.txt", "w", stdout);
#endif
}
set<int>s1,s2,tmp;
vector<int>x,y,z;
int main()
{
	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //init();
    //get_prime();
    //solve();
    int _=1;
    //cin>>_;
    while(_--){
    	int n;
    	cin>>n;
    	cout<<"? 1"<<endl;
    	for(int i=0;i<n;i++){
    		int a;
    		cin>>a;
    		if(a==1){
    			z.push_back(i+1);
			}
			if(a%2==1){
				s1.insert(i+1);
			}
			else{
				s2.insert(i+1);
			}
		}
		if(s1.size()>=s2.size()){
			tmp=s1;
			s1=s2;
			s2=tmp;
		}
		for(auto it:s1){
			if(it==1){
				for( auto itt:z){
					x.push_back(1);
					y.push_back(itt);
				}
				continue;
			}
			cout<<"? "<<it<<endl;
			for(int i=0;i<n;i++){
				int a;
				cin>>a;
				if(a==1){
					x.push_back(i+1);
					y.push_back(it);
				}
			}
		}
		cout<<"!"<<endl;
		for(int i=0;i<n;i++){
			cout<<x[i]<<" "<<y[i]<<endl;
		}
	}
    return 0;
}
