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>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define pb push_back
#define f(i,a,b) for(long long i=a;i<b;i++)
#define fr(i,a,b) for(long long i=a;i>=b;i--)
//typedef long long ll;
typedef long long ll;
#define vt vector
#define all(v)  v.begin(),v.end()
typedef vt<long long> vii;
const  long long M= 1e9+7;
template <class type1>
using ordered_multiset = tree <type1, null_type, less_equal <type1>, rb_tree_tag, tree_order_statistics_node_update>;
ll dis[2001][2001],n;
void ask(ll i)
{
    cout<<"? "<<i+1<<endl;
    f(j,0,n)
    cin>>dis[i][j];
}
int main() {

cin>>n;
ask(0);
map<ll,ll> m;
f(i,1,n)
{
    m[(dis[0][i])%2]++;
}
vector<vector<ll> > v(n);
if(m[0]<m[1])
{

    for(ll i=0;i<n;i+=2)
        if(dis[0][i]%2==0)
        ask(i);
}
else
{
    for(ll i=1;i<n;i+=2)
        if(dis[0][i]%2)
        ask(i);
}
cout<<"! "<<endl;
f(i,0,n)
{
    f(j,i+1,n)
    {
        if(dis[i][j]==1)
            cout<<i+1<<" "<<j+1<<endl;
    }
}
return 0;
}
