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;

using ll = long long;
using ld = long double;
map<pair<int,int>,bool> used;
vector<int> ask(ll r,int n)
{
    cout<<"? "<<r<<endl;
    vector<int> vec(n+1);
    for(int i=1;i<=n;++i) 
    {
        cin>>vec[i];
    }
    return vec;
}


void solve()
{
    int n;
    cin>>n;
    vector<int> vec=ask(1,n);
    int c=0;
    vector<pair<int,int>> ans;
    for(int i=1;i<=n;i++)
    {
        if(vec[i]%2==0) c+=1;
        if(vec[i]==1) {
        ans.push_back({1,i});
        used[{1,i}]=used[{i,1}]=1;
    }
    }
    if(c<=(n+1)/2) c=0;
    else c=1;
    for(int i=2;i<=n;++i)
    {
        if((vec[i]%2)==c)
        {
            vector<int> rp=ask(i,n);
            for(int j=1;j<=n;++j)
            {
                if((rp[j]==1)&&!used[{i,j}])
                {
                    used[{i,j}]=used[{j,i}]=1;
                    ans.push_back({i,j});
                }
            }
        }
    }
    cout<<"!"<<endl;
    for(int i=0;i<ans.size();i++) 
    {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
