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 <iostream>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <queue>

typedef long long ll;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

//    int test_number;
//    std::cin >> test_number;
//
//    for (int test = 0; test < test_number; ++test) {
    int n;
    std::cin >> n;

    std::vector<std::vector<int>> vertices_per_level(n);
    std::vector<int> vertex_level(n);
    std::set<std::pair<int, int>> answer;

    int even_number = 0;
    int query_vertex_level = 0;

    std::cout << "? 1" << std::endl;
    for (int i = 0; i < n; ++i) {
        std::cin >> vertex_level[i];
        vertices_per_level[vertex_level[i]].push_back(i);

        if (i > 0) {
            even_number += vertex_level[i] % 2 == 0;
        }
    }

    for (auto vertex : vertices_per_level[1]) {
        answer.insert({0, vertex});
    }

    if (even_number > n - even_number - 1) {
        query_vertex_level = 1;
    } else {
        query_vertex_level = 2;
    }

    std::vector<int> distances(n);

    for (int level = query_vertex_level; level < n; level += 2) {
        for (auto vertex : vertices_per_level[level]) {
            std::cout << "? " << vertex + 1 << std::endl;
            for (int i = 0; i < n; ++i) {
                std::cin >> distances[i];
                if (distances[i] == 1) {
                    if (i < vertex) {
                        answer.insert({i, vertex});
                    } else {
                        answer.insert({vertex, i});
                    }
                }
            }
        }
    }

    std::cout << "!\n";
    for (auto ans : answer) {
        std::cout << ans.first + 1 << " " << ans.second + 1 << "\n";
    }
    std::cout << std::endl;

    return 0;
}
