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>
#define ll long long int
#define mii map<int,int>
#define qi queue<int>
#define pqi priority_queue<int>
#define pqgi priority_queue<int,vector<int>,greater<int>>
#define si set<int>
#define vi vector<int>
#define vll vector<long long int>
#define vii vector<pair<int,int>>
#define mii map<int,int>
#define ii pair<int,int>
#define SYNC ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(j,c,d) for(int j=c;j>d;j--)
#define mod 1000000007
#define mo 998244353
#define inf 1e18
#define F first
#define S second
#define ld long double
#define INF (int)INT_MAX
#define PI 3.1415926535898
using namespace std;
const int N=1e5+5;
clock_t timeStart, timeFinish;
void timeBegin(){
	timeStart = clock();
}
void timeEnd() {
    timeFinish = clock();
}
void timeDuration() {
    double time_taken = double(timeFinish - timeStart) / double(CLOCKS_PER_SEC);
    cout << "Time taken by program is : " << fixed << time_taken << setprecision(5);
    cout << " sec " << endl;
}
/*ll po(ll A,ll B)
{
	ll RES=1;
	while(B)
	{
		if(B&1)
			RES*=A;
		B>>=1;
		A*=A;
	}
	return RES;
}*/
void solve()
{
	int n;
	cin>>n;
	int dp[n+3][n+3];si s;
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
		s.insert(i);
	int c=0;vii ans;
	while(c!=n-1)
	{
		int x=*(s.begin());
		s.erase(x);
		cout<<"? "<<x<<endl;
		int dis[n+3],cnt[n+3]={0},mp[n+3];
		for(int i=1;i<=n;i++)
		{
			cin>>dis[i];
			cnt[dis[i]]++;
			mp[dis[i]]=i;
		}
		for(int i=1;i<=n;i++)
		{
			if(i==x)continue;
			if(cnt[dis[i]-1]==1)
			{
				if(dp[mp[dis[i]-1]][i])continue;
				dp[mp[dis[i]-1]][i]=1;
				dp[i][mp[dis[i]-1]]=1;
				ans.push_back({i,mp[dis[i]-1]});
				c++;
				s.erase(i);
			}
		}
	}
	cout<<"!"<<endl;
	for(auto [a,b]:ans)
	{
		cout<<a<<" "<<b<<endl;
	}
	return;
}
int main()
{
	#ifndef ONLINE_JUDGE
    	freopen("input.txt","r",stdin);
    	freopen("output.txt","w",stdout);
	#endif
	SYNC
    //sieve();
    int t=1;
    //cin>>t;
    while(t--)
    	solve();
    //timeDuration();
    return 0;
}