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 ll long long
#define mex 400005
#define pi pair<int,int>
#define minmax(a,b) {min(a,b),max(a,b)}
int main() {
	// your code goes here
	int n;
	cin>>n;
	cout<<"? 1\n";
	cout.flush();
	int a[n];
	map<int,vector<int> > h;
	for(int i=0;i<n;i++) cin>>a[i],h[a[i]].push_back(i);
	set<pi> ed;
	int oc=0,ec=0;
	for(int i=0;i<n;i++)  if(i&1) oc += h[i].size();else ec += h[i].size();
	int in =2;
	if(ec > oc) in--;
	for(int x: h[1]) ed.insert({0,x});
	for(int i=in;i<n;i+=2)
	{
	    if(ed.size() == n-1) break;
	    for(int x:h[i])
	    {
	        cout<<"? "<<x+1<<'\n';
	        cout.flush();
	        for(int i=0;i<n;i++) {
	            cin>>a[i];
	            if(a[i] == 1) ed.insert(minmax(x,i));
	        }
	    }
	}
	cout<<"!\n";
	auto it = ed.begin();
	while(it != ed.end())
	{
	    cout<<(*it).first + 1 << ' ' << (*it).second+1<<'\n';
	    it++;
	}
	return 0;
}
