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 pll              pair<long,long>
#define pii              pair<int,int>
#define scn(a)           scanf("%d", &a)
#define scn2(a, b)       scanf("%d%d", &a, &b)
#define scn3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pairl            pair<ll , ll >
#define scnl(a)          scanf("%lld", &a)
#define scnl2(a, b)      scanf("%lld%lld", &a, &b)
#define scnl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define scns(s)          scanf("%s",s)
#define prts(s)          printf("%s\n",s)
#define prt(a)           printf("%d\n", a)
#define prtl(a)          printf("%lld\n", a)
#define prs(a)           printf("%d ", a)
#define prt2(a, b)       printf("%d %d\n", a, b)
#define prt3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)          printf("%lld ", a)
#define prtl2(a, b)      printf("%lld %lld\n", a, b)
#define prtl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define ptcs(a)          printf("Case %d: ", a)
#define pf               printf
#define S                second
#define F                first
#define sc               scanf
#define vi               vector<int >
#define vil              vector<ll >
#define pb               push_back
#define mem(a, b)        memset((a), (b), sizeof(a))
#define lg2(n)           (31-__builtin_clz(n))
#define inf              9999999
#define PI               acos(-1.0)
#define ll               long long
#define ull              unsigned long long
#define MIN              INT_MIN
#define MAX              INT_MAX
#define fast             ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
const int N = 4e3 + 5;
const int mod = 1e9 + 7;
typedef tree<pair<int, int> , null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
ll x,y,n,m,t,k,k1,mx,x1,x2,x3,x4,x5,ans,q,a,l,r,b;
bool vis[N];
ll ar[N],br[N],le[N],ri[N],pa[N];
vector<pll>v;
vector<ll>prime,v1[N];
map<ll,ll>mp,mp1;
string s,s2,s3,s4;
void qe()
{
	cout<<"? 1"<<endl;
	for(int i=1;i<=n;i++)
	{
		cin>>ar[i];
		if(ar[i]==1) v.pb({1,i});
	}
	vis[1]=1;
}
void qee(ll u)
{
	vis[u]=1;
	cout<<"? "<<u<<endl;
	for(int i=1;i<=n;i++) cin>>br[i];
	for(int i=2;i<=n;i++)
	{
		if(br[i]==1)
		{
			v.pb({u,i});
			if(ar[i]>ar[u]) ar[i]=0;
		}
	}
	ar[u]=0;
}
int main()
{
    fast;
    cin>>n;
    if(n==2)
    {
    	cout<<"!"<<endl;
    	cout<<"1 2"<<endl;
    	return 0;
    }
    qe();
    y=1;
    while(true)
    {
    	x=0;
    	for(int i=1;i<=n;i++) x=max(x,ar[i]);
    	if(x<=1) break;
    	for(int i=1;i<=n;i++)
    	{
    		if(ar[i]==x-1)
    		{
    			y++;
    			qee(i);
    			break;
    		}
    	}
        assert(y<=(n+1)/2);
    }
    cout<<"!"<<endl;
    assert(y<=(n+1)/2);
    for(auto xx : v)
    {
    	cout<<xx.F<<' '<<xx.S<<endl;
    }
    return 0;
}
