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

//Date 13/06/2021
//LAtoken Round 1
#include <bits/stdc++.h>
using namespace std;

typedef  long long     ll;
typedef  vector<int>   vi;
typedef  pair<int,int> pii;

#define   all(x)        (x).begin(),(x).end()
#define   rep(i,a,b)    for(ll i = a; i<b ; i++)
#define   sz(x)         (int)((x).size())
#define   PI             3.141592653589
#define   mod            1000000007 
#define   MAX            1000005 //1e6+5
#define   ppc             __builtin_popcount
#define   ppcll           __builtin_popcountll
long long const INF = 1e13;

ll power(ll a, ll b) 
{   ll result =1;
    while(b)
    {   if(b%2) result=(result*a)%mod;    
        a=(a*a)%mod;
        b/=2;}
    return result;
}

void cfl()
{
    int n; cin>>n;
    set<pii> s;
    cout<<"? 1"<<endl;
    cout<<flush;
    map<int,vi> label;
    int e =0,o=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        label[x].push_back(i);
        if(x!=0)
        {
            if(x%2==0) e++;
            else o++;
        }
        if(x==1)
        {
            s.insert({1,i});
        }
    }
    //odd label or even label ask 
    vector<vi> ask(2); //even odd
    for(auto i:label)
    {
        if(i.first==0) continue;
        for(auto j:i.second)
        {
            ask[(i.first)%2].push_back(j);
        }
    }
    // for(auto i:ask)
    // {
    //     for(auto j: i)
    //     {
    //         cout<<j<<" ";
    //     }
    //     cout<<"\n";}
    
    int f;
    if(e<=o)  f=0;
    else f=1;
    
        for(int i=0;i<sz(ask[f]);i++)
        {
            cout<<"? "<<ask[f][i]<<endl;
            cout<<flush;
            for(int j=1;j<=n;j++)
            {
                int x; cin>>x;
                if(x==1) {
                    if(s.find({ask[f][i],j})==s.end())
                    s.insert({j,ask[f][i]});
                }
            }
        }
    
    cout<<"!"<<endl;
    for(auto i:s)
    {
        cout<<i.first<<" "<<i.second<<endl;
        cout<<flush;
    }
    

}
int main() 
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);cout.tie(NULL);
    int T=1; //cin>>T;
    while(T--) cfl();
    return 0;
}