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;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << ": "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(int t) {cerr << t;}
void _print(long long t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(double t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ", "; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[  "; for (T i : v) {_print(i); cerr << "  ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[  "; for (T i : v) {_print(i); cerr << "  ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[  "; for (T i : v) {_print(i); cerr << "  ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[  "; for (auto i : v) {_print(i); cerr << "  ";} cerr << "]";}


int32_t main() {

    int n;
    cin >> n;

    set<pair<int,int>> edges;

    vector<int> dist(n+1);

    cout << "? 1" << endl;
    for(int i = 1; i <= n; i++) cin >> dist[i];

    vector<int> s1, s2;
    for(int i = 1; i <= n; i++){
        if(dist[i] & 1) s2.push_back(i);
        else s1.push_back(i);
    }

    vector<int> nodes;
    if(s1.size() <= s2.size()) nodes = s1;
    else nodes = s2;

    for(int x : nodes){
        if(x != 1){
            cout << "? " << x << endl;
            for(int i = 1; i <= n; i++){
                int v;
                cin >> v;
                if(v == 1){
                    edges.insert({min(x, i), max(x, i)});
                }
            }
        }
        else{
            for(int i = 1; i <= n; i++){
                int v = dist[i];
                if(v == 1){
                    edges.insert({min(x, i), max(x, i)});
                }
            }
        }
    }

    cout << "!" << endl;
    for(auto p : edges) cout << p.first << ' ' << p.second << endl;


}

/*


*/


