**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Turtle and Intersected Segments
time_limit_ms: 5000
memory_limit_mb: 512
Description: Turtle just received $n$ segments and a sequence $a_1, a_2, \ldots, a_n$. The $i$-th segment is $[l_i, r_i]$.

Turtle will create an undirected graph $G$. If segment $i$ and segment $j$ intersect, then Turtle will add an undirected edge between $i$ and $j$ with a weight of $|a_i - a_j|$, for every $i \ne j$.

Turtle wants you to calculate the sum of the weights of the edges of the minimum spanning tree of the graph $G$, or report that the graph $G$ has no spanning tree.

We say two segments $[l_1, r_1]$ and $[l_2, r_2]$ intersect if and only if $\max(l_1, l_2) \le \min(r_1, r_2)$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^5$). The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \le n \le 5 \cdot 10^5$) — the number of segments.

The $i$-th of the following $n$ lines contains three integers $l_i, r_i, a_i$ ($1 \le l_i \le r_i \le 10^9, 1 \le a_i \le 10^9$) — the $i$-th segment and the $i$-th element of the sequence.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a single integer — the sum of the weights of the edges of the minimum spanning tree of the graph $G$. If the graph $G$ has no spanning tree, output $-1$.

Examples:
input:
4
5
1 7 3
2 4 6
3 5 5
6 7 9
3 4 4
5
2 7 3
1 3 6
4 5 5
6 7 9
1 1 4
4
1 4 3
1 2 1
3 4 5
1 4 4
3
1 3 1
2 3 3
4 5 8
output:
9
13
4
-1

Note: In the first test case, the graph $G$ is as follows:

![](CDN_BASE_URL/7b0a32f8f1d54a5dbbaffee1efd8ece1)

One of the minimum spanning trees of $G$ is as follows:

![](CDN_BASE_URL/7a035af2d5227648781d0c24b81c076e)

The sum of the weights of the edges of the minimum spanning tree is $9$.

In the second test case, the graph $G$ is as follows:

![](CDN_BASE_URL/62be880a08fa85071b491d6badd5f58e)

$G$ is already a tree, and the sum of the weights of the tree is $13$.

In the third test case, the graph $G$ is as follows:

![](CDN_BASE_URL/b667aa771d019e3a8a3a4c4372200f03)

In the fourth test case, the graph $G$ is as follows:

![](CDN_BASE_URL/45bc2d052677dbf032ff37fd1d723d83)

It's easy to see that $G$ is not connected, so $G$ has no spanning tree.

Buggy Code:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Segment {
    int l, r, a;
};

struct Edge {
    int u, v, w;
    bool operator<(const Edge &other) const {
        return w < other.w;
    }
};

int find(int parent[], int i) {
    if (parent[i] == i)
        return i;
    return parent[i] = find(parent, parent[i]);
}

void unionSet(int parent[], int rank[], int x, int y) {
    int xroot = find(parent, x);
    int yroot = find(parent, y);

    if (rank[xroot] < rank[yroot])
        parent[xroot] = yroot;
    else if (rank[xroot] > rank[yroot])
        parent[yroot] = xroot;
    else {
        parent[yroot] = xroot;
        rank[xroot]++;
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<Segment> segs(n);
        for (int i = 0; i < n; ++i) {
            cin >> segs[i].l >> segs[i].r >> segs[i].a;
        }

        vector<Edge> edges;
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                if (max(segs[i].l, segs[j].l) <= min(segs[i].r, segs[j].r)) {
                    edges.push_back({i, j, abs(segs[i].a - segs[j].a)});
                }
            }
        }

        sort(edges.begin(), edges.end());

        int parent[n], rank[n];
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
            rank[i] = 0;
        }

        long long mstWeight = 0;
        int numEdges = 0;
        for (auto &edge : edges) {
            int x = find(parent, edge.u);
            int y = find(parent, edge.v);
            if (x != y) {
                unionSet(parent, rank, x, y);
                mstWeight += edge.w;
                numEdges++;
            }
        }

        if (numEdges != n - 1)
            cout << "-1\n";
        else
            cout << mstWeight << "\n";
    }
    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4
1 2 1
2 3 1
3 4 1
4 5 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Turtle and Intersected Segments
time_limit_ms: 5000
memory_limit_mb: 512
Description: Turtle just received $n$ segments and a sequence $a_1, a_2, \ldots, a_n$. The $i$-th segment is $[l_i, r_i]$.

Turtle will create an undirected graph $G$. If segment $i$ and segment $j$ intersect, then Turtle will add an undirected edge between $i$ and $j$ with a weight of $|a_i - a_j|$, for every $i \ne j$.

Turtle wants you to calculate the sum of the weights of the edges of the minimum spanning tree of the graph $G$, or report that the graph $G$ has no spanning tree.

We say two segments $[l_1, r_1]$ and $[l_2, r_2]$ intersect if and only if $\max(l_1, l_2) \le \min(r_1, r_2)$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^5$). The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \le n \le 5 \cdot 10^5$) — the number of segments.

The $i$-th of the following $n$ lines contains three integers $l_i, r_i, a_i$ ($1 \le l_i \le r_i \le 10^9, 1 \le a_i \le 10^9$) — the $i$-th segment and the $i$-th element of the sequence.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a single integer — the sum of the weights of the edges of the minimum spanning tree of the graph $G$. If the graph $G$ has no spanning tree, output $-1$.

Examples:
input:
4
5
1 7 3
2 4 6
3 5 5
6 7 9
3 4 4
5
2 7 3
1 3 6
4 5 5
6 7 9
1 1 4
4
1 4 3
1 2 1
3 4 5
1 4 4
3
1 3 1
2 3 3
4 5 8
output:
9
13
4
-1

Note: In the first test case, the graph $G$ is as follows:

![](CDN_BASE_URL/7b0a32f8f1d54a5dbbaffee1efd8ece1)

One of the minimum spanning trees of $G$ is as follows:

![](CDN_BASE_URL/7a035af2d5227648781d0c24b81c076e)

The sum of the weights of the edges of the minimum spanning tree is $9$.

In the second test case, the graph $G$ is as follows:

![](CDN_BASE_URL/62be880a08fa85071b491d6badd5f58e)

$G$ is already a tree, and the sum of the weights of the tree is $13$.

In the third test case, the graph $G$ is as follows:

![](CDN_BASE_URL/b667aa771d019e3a8a3a4c4372200f03)

In the fourth test case, the graph $G$ is as follows:

![](CDN_BASE_URL/45bc2d052677dbf032ff37fd1d723d83)

It's easy to see that $G$ is not connected, so $G$ has no spanning tree.

Buggy Code:
#include <bits/stdc++.h>
using namespace std;

struct UnionFind {
    vector<int> parent, rank;
    UnionFind(int n) : parent(n), rank(n, 1) {
        for (int i = 0; i < n; ++i) parent[i] = i;
    }
    int find(int u) {
        if (parent[u] != u) parent[u] = find(parent[u]);
        return parent[u];
    }
    void unite(int u, int v) {
        u = find(u);
        v = find(v);
        if (u == v) return;
        if (rank[u] < rank[v]) swap(u, v);
        parent[v] = u;
        if (rank[u] == rank[v]) rank[u]++;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<array<int, 3>> segments(n);
        for(auto &s : segments){
            cin >> s[0] >> s[1] >> s[2];
        }
        vector<tuple<int, int, int>> edges;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                if(max(segments[i][0], segments[j][0]) <= min(segments[i][1], segments[j][1])){
                    int weight = abs(segments[i][2] - segments[j][2]);
                    edges.emplace_back(weight, i, j);
                }
            }
        }
        sort(edges.begin(), edges.end());
        UnionFind uf(n);
        long long mst_weight = 0;
        int edges_added = 0;
        for(auto [weight, u, v] : edges){
            if(uf.find(u) != uf.find(v)){
                uf.unite(u, v);
                mst_weight += weight;
                edges_added++;
                if(edges_added == n-1) break;
            }
        }
        if(edges_added == n-1){
            cout << mst_weight << "\n";
        } else {
            cout << "-1\n";
        }
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the given code, we need to consider edge cases that might cause the algorithm to fail. The primary issues to consider are:

1. **Disconnected Graph**: The graph might not be connected, and the code should correctly identify this and output `-1`.
2. **Edge Cases in Segment Intersections**: Segments that just touch each other (e.g., `[1, 1]` and `[1, 2]`) should be considered intersecting.
3. **Large Number of Segments**: While the test input should be small-scale, it should still be complex enough to challenge the algorithm.

Let's construct a test case that includes these elements:

### Test Case 1: Disconnected Graph
- We will create two segments that do not intersect, ensuring the graph is not connected.

### Test Case 2: Edge Cases in Segment Intersections
- We will create segments that just touch each other to test the intersection logic.

### Test Case 3: Multiple Segments with Intersections
- We will create a set of segments that form a connected graph, but with a complex structure to ensure the MST algorithm works correctly.

### Test Case 4: Segments with Equal Weights
- We will create segments with the same weight to test the edge weight comparison logic.

Here is the test input:

```plaintext
4
2
1 2 3
3 4 5
3
1 1 1
2 2 2
3 3 3
4
1 2 1
2 3 3
3 4 5
4 5 4
5
1 2 1
2 3 1
3 4 1
4 5 1
5 6 1
```

### Explanation:
1. **Test Case 1**: Two segments `[1, 2]` and `[3, 4]` do not intersect, so the graph is not connected. The expected output is `-1`.
2. **Test Case 2**: Three segments `[1, 1]`, `[2, 2]`, and `[3, 3]` do not intersect, so the graph is not connected. The expected output is `-1`.
3. **Test Case 3**: Four segments `[1, 2]`, `[2, 3]`, `[3, 4]`, and `[4, 5]` form a connected graph. The expected output is the sum of the weights of the MST.
4. **Test Case 4**: Five segments `[1, 2]`, `[2, 3]`, `[3, 4]`, `[4, 5]`, and `[5, 6]` all have the same weight. The expected output is the sum of the weights of the MST.

This test input should effectively expose any bugs in the given code.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

int query(int a, int b) {
    cout << "? " << a << " " << b << endl;
    int x;
    cin >> x;
    return x;
}

void solve(int n) {
    vector<pair<int, int>> edges;

    vector<int> parent(n + 1, -1);
    parent[1] = 1;

    for (int i = 2; i <= n; i++) {
        int p = query(1, i);
        parent[i] = p;

        if (p == 1) {
            edges.push_back({1, i});
        } else {
            edges.push_back({p, i});
        }
    }

    cout << "! ";
    for (auto edge : edges) {
        cout << edge.first << " " << edge.second << " ";
    }
    cout << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        solve(n);
    }
    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, let's analyze the code and identify potential issues:

### Analysis of the Buggy Code
1. **Query Mechanism**: The code queries the node that minimizes the distance difference between two nodes.
2. **Parent Assignment**: The code assigns the queried node as the parent of the current node.
3. **Edge Construction**: The code constructs edges based on the parent assignments.

### Potential Bugs
1. **Parent Assignment**: The code assumes that the queried node is always the correct parent. This might not always be the case, especially in complex tree structures.
2. **Edge Construction**: The code constructs edges directly from the queried node to the current node, which might lead to incorrect tree structures.

### Challenging Test Input
To expose the bug, we need a test case where the queried node does not always represent the correct parent, leading to incorrect edge construction.

### Example Test Input
Consider a tree with 4 nodes where the structure is as follows:
- Node 1 is connected to Node 2.
- Node 2 is connected to Node 3.
- Node 3 is connected to Node 4.

This tree structure can be represented as:
```
1 - 2 - 3 - 4
```

### Expected Queries and Responses
- Query "? 1 2" should return 1 (since the distance difference is minimized at node 1).
- Query "? 1 3" should return 2 (since the distance difference is minimized at node 2).
- Query "? 1 4" should return 3 (since the distance difference is minimized at node 3).

### Test Input
```plaintext
1
4
```

### Explanation
- The test input consists of a single test case with 4 nodes.
- The structure of the tree is such that the queries will expose the bug in the parent assignment logic.
- The correct edges should be: (1, 2), (2, 3), and (3, 4).

This test input will challenge the buggy code to correctly identify the parent nodes and construct the tree.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
ifstream fin ("k.in");
ofstream fout ("k.out");

vector<int> graf[1005];
int tati[1005];
vector<pair<int,int>> intrebari;
pair<int,int> p;
int main()
{
    ios_base::sync_with_stdio(0);
    int n,m,i,j,k,t,q,maxim,nr;

    cin>>t;
    while(t--)
    {
        cin>>n;
        q=0;
        tati[1]=1;
        for(i=2;i<=n;i++)
        {
            intrebari.push_back({1,i});
        }
        while(!intrebari.empty() && q<15*n)
        {
            p=intrebari.back();
            intrebari.pop_back();
            if(tati[p.first] && tati[p.second])
                continue;
            cout<<"? "<<p.first<<' '<<p.second<<' ';
            cout.flush();
            cin>>k;
            q++;
            if(k==p.first)
            {
                tati[p.second]=p.first;
            }
            else
            {
                cout<<"? "<<p.second<<' '<<p.first<<' ';
                cout.flush();
                cin>>j;
                q++;
                if(j==k)
                {
                    if(p.first<k)
                    intrebari.push_back({p.first,k});
                    else
                    intrebari.push_back({k,p.first});
                    if(p.second<k)
                    intrebari.push_back({p.second,k});
                    else
                    intrebari.push_back({k,p.second});
                }
                else
                {
                    if(k>j)
                    tati[k]=j;
                    else
                    tati[j]=k;

                    if(p.first<k)
                    intrebari.push_back({p.first,k});
                    else
                    intrebari.push_back({k,p.first});

                    if(p.second<j)
                    intrebari.push_back({p.second,j});
                    else
                    intrebari.push_back({j,p.second});
                }
            }

        }
        cout<<"! ";
        if(q==15*n)
            cout<<1/0;
        else
            for(i=2;i<=n;i++)
        {
            cout<<tati[i]<<' '<<i<<' ';
        }

    }

    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <stack>
#include <set>
#include <vector>
using namespace std;
#define int long long
int maxi = 1e6+5;
int mod = 1e9+7;
vector<int> p;
set<int> ae;
int ec;
vector<pair<int, int>> edges;

void query(int a, int b){
    cout << "? " << a << " " << b << endl;
}

void answer(vector<pair<int, int>> &a){

    cout << "! ";
    for(auto p : a){
        cout << p.first << " " << p.second << " ";
    }
    cout << endl;
}

void find(int A, int B){
    while(true){
        query(A, B);
        int r; cin >> r;

        if(r == A){
            edges.push_back(make_pair(r, B));
            break;
        }
        else{
            A = r;
        }
    }
}

void solve(void){
    int N; cin >> N;

    for(int i = 2; i <= N; i++) find(1, i);

    answer(edges);
}

int32_t main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int T = 1;
    cin >> T;
    while(T--) solve();

    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To expose the bug in the given code, we need to focus on scenarios where the algorithm might fail to correctly identify the edges of the tree. The primary issue with the code is that it always starts from node 1 and tries to find edges by querying node 1 with every other node. This approach can fail if the tree structure is such that node 1 is not a central node, or if the tree has a more complex structure that cannot be fully reconstructed by always starting from node 1.

### Step-by-Step Reasoning:
1. **Tree Structure**: Consider a tree where node 1 is not a central node. For example, a tree where node 1 is a leaf node.
2. **Query Behavior**: If node 1 is a leaf, the queries starting from node 1 will not provide enough information to reconstruct the entire tree.
3. **Example Tree**: A simple example is a linear tree (path) where node 1 is one of the endpoints.

### Test Input:
Let's create a test input with a linear tree where node 1 is a leaf node. This will ensure that the algorithm fails to correctly identify the edges because it always starts from node 1.

```plaintext
1
4
1
2
3
4
```

### Explanation:
- **Test Case**: There is one test case with 4 nodes.
- **Tree Structure**: The tree is a linear path: 1 - 2 - 3 - 4.
- **Queries**:
  - Query `? 1 2` will return 1 (since 1 is closer to 2 than any other node).
  - Query `? 1 3` will return 1 (since 1 is closer to 3 than any other node).
  - Query `? 1 4` will return 1 (since 1 is closer to 4 than any other node).

The algorithm will incorrectly identify the edges because it will only find edges from node 1 to nodes 2, 3, and 4, which is not the correct structure of the tree.

### Expected Output:
The correct edges of the tree are:
- (1, 2)
- (2, 3)
- (3, 4)

However, the algorithm will output:
- (1, 2)
- (1, 3)
- (1, 4)

This incorrect output exposes the bug in the code.

```plaintext
1
4
1
2
3
4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
import sys
import random

def query(a, b):
    print(f"? {a} {b}")
    sys.stdout.flush()
    return int(input())

def find_center(n):
    if n == 1:
        return 1
    a = random.randint(1, n)
    b = random.randint(1, n)
    while b == a:
        b = random.randint(1, n)
    c = query(a, b)
    if c == a:
        return a
    elif c == b:
        return b
    else:
        return find_center(n)

def find_edges(n, center):
    edges = []
    for i in range(1, n + 1):
        if i != center:
            a = query(center, i)
            if a == center:
                edges.append((center, i))
            else:
                edges.append((a, i))
    return edges

def solve(n):
    center = find_center(n)
    edges = find_edges(n, center)
    return edges

def main():
    t = int(input())
    for _ in range(t):
        n = int(input())
        edges = solve(n)
        print("!", end=" ")
        for a, b in edges:
            print(a, b, end=" ")
        print()
        sys.stdout.flush()

if __name__ == "__main__":
    main()

# Ag7CTQ4vx1SM0pJVFWl

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To expose the bug in the provided code, we need to focus on edge cases and scenarios that can cause the algorithm to fail. The main issues in the code are:

1. **Random Selection of Nodes**: The `find_center` function uses random nodes to find the center, which can lead to incorrect results if the random nodes are not chosen well.
2. **Handling of Queries**: The `find_edges` function assumes that the center is always correct, which may not be the case if the center is not properly identified.

A challenging test input that can expose these issues is a linear tree (a path) where the center is not easily identifiable by random queries. For a small-scale test, a tree with 4 nodes in a linear structure (1-2-3-4) can be used.

Here is the test input:

```plaintext
1
4
```

This input represents a single test case with a tree of 4 nodes. The tree is a simple path: 1-2-3-4. This structure can challenge the random selection in `find_center` and the assumptions in `find_edges`.

### Explanation:
- **Test Case**: `1` indicates one test case.
- **Number of Nodes**: `4` indicates the tree has 4 nodes.

For this tree:
- The center should be either node 2 or node 3.
- If the random selection in `find_center` does not correctly identify the center, the `find_edges` function will likely produce incorrect edges.

This test input should help expose the bugs in the code by making it difficult for the random selection to find the correct center and by testing the assumptions in the edge-finding process.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
import sys

def query(a, b):
    print(f'? {a} {b}')
    sys.stdout.flush()
    return int(input())

def solve():
    n = int(input())
    edges = []
    for i in range(2, n + 1):
        x = query(1, i)
        edges.append((x, i))

    # Additional logic might be needed to ensure all edges are captured correctly
    print('!', end=' ')
    for a, b in edges:
        print(a, b, end=' ')
    print()
    sys.stdout.flush()

t = int(input())
for _ in range(t):
    solve()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5
1
2
3
4
5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
def solve():
    t = int(input().strip())

    for _ in range(t):
        n = int(input().strip())

        edges = []

        for i in range(2, n + 1):
            print(f"? 1 {i}")
            response = int(input().strip())

            if response == 1:
                edges.append((1, i))
            else:
                edges.append((response, i))

        answer = "! " + " ".join(f"{a} {b}" for a, b in edges)
        print(answer)

solve()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int t = sc.nextInt();
        while (t-- > 0) {
            solve();
        }
    }

    static void solve() {
        int n = sc.nextInt();
        List<int[]> edges = new ArrayList<>();

        for (int i = 2; i <= n; i++) {
            int x = query(1, i);
            edges.add(new int[] {x, i});
        }

        System.out.print("!");
        for (int[] edge : edges) {
            System.out.print(" " + edge[0] + " " + edge[1]);
        }
        System.out.println();
        System.out.flush();
    }

    static int query(int a, int b) {
        System.out.println("? " + a + " " + b);
        System.out.flush();
        return sc.nextInt();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided code, we need to focus on edge cases and scenarios that can highlight issues in the algorithm. The code provided queries the minimum distance node between node 1 and each other node from 2 to n, and then assumes that the node returned by the query is directly connected to the queried node. This assumption can fail in certain tree structures, especially those with more complex branching.

### Step-by-Step Analysis

1. **Understanding the Bug**: The code assumes that the node returned by the query is directly connected to the queried node. This is not always true, especially in trees with more complex structures.

2. **Challenging Scenario**: A tree where node 1 is not directly connected to all other nodes, and the minimum distance node returned by the query is not the direct neighbor.

3. **Example Tree**:
   - Node 1 is connected to node 2.
   - Node 2 is connected to node 3.
   - Node 3 is connected to node 4.
   - This structure ensures that the minimum distance node for queries involving node 1 and nodes 3 or 4 is not directly connected to node 1.

### Test Input

```plaintext
1
4
```

### Explanation

- **Test Case**: 1
- **Number of Nodes**: 4

### Expected Behavior

- **Query "? 1 2"**: The minimum distance node is 1 (since 1 is directly connected to 2).
- **Query "? 1 3"**: The minimum distance node is 2 (since 2 is the closest to both 1 and 3).
- **Query "? 1 4"**: The minimum distance node is 2 (since 2 is the closest to both 1 and 4).

### Expected Output

- The code should output the edges of the tree.
- The correct edges are: (1, 2), (2, 3), (3, 4).

### Actual Output

- The code will output: (1, 2), (2, 3), (2, 4), which is incorrect because it assumes 2 is directly connected to 4.

### Conclusion

This test input will expose the bug in the code by showing that the assumption of direct connection based on the query result is incorrect in certain tree structures. The correct structure of the tree is not accurately reconstructed, leading to a failure in the algorithm.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Codeforces3 {

  public static PrintWriter out;

  public static void main(String... args) {
    final FastScanner fastScanner = new FastScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int tests = fastScanner.nextInt();
    // int tests = 1;
    for (int i = 0; i < tests; i++) {
      int n = fastScanner.nextInt();
//      int[] arr = new int[n];
//      for (int j = 0; j < n; j++) {
//        arr[j] = fastScanner.nextInt();
//      }

      int[] res = solve(n);
      out.print("! ");
      for (int j = 0; j < res.length; j++) {
        out.print(res[j]);
        if (j < res.length - 1) {
          out.print(" ");
        }
      }
      out.println();
      out.flush();
      // out.println(res);

    }

    out.close();
  }

  private static int[] solve(int n) {
    if (n == 1) {
      return new int[0];
    }
    int[] answer = new int[2 * n - 2];
    boolean[] marked = new boolean[n + 1];
    final FastScanner fastScanner = new FastScanner();
    int k = 0;
    for (int i = 1; i <= n; i++) {
      if (marked[i]) {
        continue;
      }
      int j = (i == n ? 1 : n);
      int w = n;
      while (j != i) {
        out.println("? " + i + " " + (j == -1 ? (i != n ? n : 1) : j));
        out.flush();
        w = j;
        j = fastScanner.nextInt();
        if (j == -1) {
          return new int[] {0, 1};
        }
      }
      answer[k++] = i;
      answer[k++] = w;
      marked[i] = true;
      marked[w] = true;
    }
    return answer;
  }

  private static int[] arrayFromString(final String input) {
    return Arrays.stream(input.split(" "))
        .mapToInt(Integer::parseInt)
        .toArray();
  }

  static class FastScanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");

    String next() {
      while (!st.hasMoreTokens()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }
  }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the given buggy code, we need to consider the following points:

1. **Edge Cases**: The code should handle edge cases such as small trees and specific node configurations.
2. **Complex Trees**: The code should be tested with more complex tree structures to ensure it can handle various scenarios.
3. **Interactive Queries**: The code should be able to correctly interpret and respond to the queries.

The buggy code has a few issues:
- It does not correctly handle the case where the node `j` is already marked.
- It does not correctly handle the case where the node `j` is the same as `i`.

Given these points, a small-scale test input that can expose these issues is a tree with 4 nodes, where the structure is not straightforward and requires careful handling of the queries.

Here is the test input:

```plaintext
1
4
```

This input will create a single test case with 4 nodes. The tree structure can be as follows:
- Node 1 is connected to Node 2.
- Node 1 is connected to Node 3.
- Node 3 is connected to Node 4.

This structure requires the code to correctly handle the queries and ensure that it can correctly identify the edges. The expected queries and responses are:
- `? 1 2` -> Response: `1`
- `? 1 3` -> Response: `1`
- `? 1 4` -> Response: `3`

This test case should help expose the issues in the buggy code where it might incorrectly handle the marked nodes or the node configurations.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
// 人外有人，天外有天
// author: Ausp3x

#pragma GCC optimize("O1, O2, O3, Ofast, unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define pb push_back
// #define DEBUG
typedef long long    lng;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int const INF32 = 0x3f3f3f3f;
lng const INF64 = 0x3f3f3f3f3f3f3f3f;

struct UnionFind {
    int n;
    vector<int> link, node_size, edge_size;

    UnionFind(int n): n(n) {
        link.resize(n + 1);
        iota(link.begin(), link.end(), 0);
        node_size.resize(n + 1, 1);
        edge_size.resize(n + 1);
    }

    int findSet(int v) {
        if (v == link[v]) {
            return link[v];
        }

        return link[v] = findSet(link[v]);
    }

    bool isSameSet(int a, int b) {
        return findSet(a) == findSet(b);
    }

    void uniteSets(int a, int b) {
        a = findSet(a);
        b = findSet(b);
        if (node_size[a] < node_size[b]) {
            swap(a, b);
        }

        if (a == b) {
            edge_size[a]++;
            return;
        }

        node_size[a] += node_size[b];
        edge_size[a] += edge_size[b] + 1;
        link[b] = a;

        return;
    }

    void debugPrint() {
        cout << n << endl;
        cout << "link:" << endl;
        for (int x : link)
            cout << x << ' ';
        cout << endl;
        cout << "node_size:" << endl;
        for (int x : node_size)
            cout << x << ' ';
        cout << endl;
        cout << "edge_size:" << endl;
        for (int x : edge_size)
            cout << x << ' ';
        cout << endl;

        return;
    }
};

int n;
int query_cnt;
vector<vector<int>> memo;
set<pair<int, int>> edges;
void dp(int a, int b, UnionFind &uf) {
    if (memo[a][b] != -1 || uf.isSameSet(a, b))
        return;

    assert(query_cnt < 15 * n);
    cout << "? " << a << ' ' << b << endl;
    cin >> memo[a][b];
    query_cnt++;

    if (memo[a][b] == a) {
        edges.insert({min(a, b), max(a, b)});
        uf.uniteSets(a, b);
        return;
    }

    dp(a, memo[a][b], uf);
    dp(memo[a][b], b, uf);

    return;
}

void solve() {
    cin >> n;

    query_cnt = 0;
    memo.clear();
    memo.resize(n + 1, vector<int>(n + 1, -1));
    UnionFind uf(n);
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) {
            if (uf.isSameSet(i, j))
                continue;

            dp(i, j, uf);
        }

    assert(edges.size() >= n - 1);
    cout << "! ";
    for (auto &[a, b] : edges)
        cout << a << ' ' << b << ' ';
    cout << endl;

    return;
}

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

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To create a challenging test input that exposes the bug in the provided code, we need to focus on edge cases and scenarios that can maximize the failure probability. The code uses a Union-Find data structure to manage the connectivity of nodes and a depth-first search (DFS) approach to determine the edges of the tree. Here are the steps to think through the problem:

1. **Understand the Bug**: The code uses a DFS approach to determine the edges. If the tree is structured in a way that the DFS can easily get confused or miss edges, it will fail.

2. **Edge Cases**:
   - **Linear Tree**: A tree where nodes are connected in a straight line.
   - **Star Tree**: A tree where one node is connected to all other nodes.
   - **Balanced Tree**: A tree where the nodes are distributed evenly.

3. **Challenging Scenario**: A balanced tree with a specific structure that can confuse the DFS. For example, a tree where the root has two children, and each child has a subtree of equal size.

Given the constraints and the need for a small-scale test input, let's create a balanced tree with 7 nodes (a small but complex enough structure):

```
1
7
```

This input represents a single test case with 7 nodes. The tree structure could be as follows:

```
      1
     / \
    2   3
   / \ / \
  4  5 6  7
```

This tree is balanced and has a structure that can challenge the DFS approach. The nodes 2 and 3 each have two children, and the root node 1 has two children. This structure can make it difficult for the DFS to correctly determine the edges if it doesn't handle the queries in an optimal order.

Here is the test input:

```plaintext
1
7
```

This input will test the algorithm's ability to correctly identify the edges in a balanced tree structure.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
#include <bits/stdc++.h>
using namespace std;
#define OUT cout << setprecision(7) << fixed;
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define all(ans) ans.begin(), ans.end()
#define sz(x) ((int)(x).size())
#define rall(x) (x).rbegin(), (x).rend()
vector<int> dx = {0, 0, -1, 1}, dy = {-1, 1, 0, 0};
typedef long long ll;
typedef long double ld;

#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define pt pair<ll, ll>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
const long double eps = 1e-9;
const int N = 1e5 ;
vector<int> visted(N) ;
set<pair<int,int>> edgs ;
ll n , m , x , y , k ;
void ins(int a , int b){
    if (a > b)
        swap(a,b) ;
    edgs.insert({a,b}) ;
}
int ask(int a , int b){
    cout <<"? " << a << " " << b << endl ;
    int x ;
    cin >> x ;
    return x ;
}
void dfs(int x ){
    if (!visted[x]){
        visted[x] = true ;
        for (int i = 1 ; i <= n ; i++ ){
            if (!visted[i]){
                int to = ask(x , i) ;
                if (x != to){
                    ins(x , to) ;
                }
                if (!visted[i] && to == x){
                    int y = ask(i , x) ;
                    if (y == i){
                        ins(x, i) ;
                    }
                    if (!visted[i]){
                        dfs(i) ;
                        continue ;
                    }
                }
                if (!visted[to])
                    dfs(to) ;
            }
        }
    }
}
void solve(){
    cin >> n ;
    edgs.clear() ;
    for (int i = 0 ; i <= n ; i++){
        visted[i] = false ;
    }
    for (int i = 1 ; i <= n ; i++){
        if(!visted[i])
            dfs(i) ;
    }
    cout << "! " ;
    for(auto[x,y] : edgs){
        cout << x << " " << y << " " ;
    }
    cout << endl ;
}

int main(){

    int tt = 1;
    cin >> tt;
    while (tt--){
        solve();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4
```

**Explanation:**

This test case is designed to challenge the given buggy code by focusing on a small tree with 4 nodes. The structure of the tree is not explicitly defined, but the algorithm should be able to deduce it through the queries.

The key points to consider are:
1. **Query Efficiency:** The code should be able to correctly determine the structure of the tree using a minimal number of queries.
2. **Edge Cases:** The code should handle cases where the tree is not a simple linear structure (e.g., a star or a more complex branching structure).

For a tree with 4 nodes, the possible structures include:
- A linear structure (e.g., 1-2-3-4)
- A star structure (e.g., 1-2, 1-3, 1-4)
- A more complex structure (e.g., 1-2, 1-3, 3-4)

The test case provided (4 nodes) is small enough to ensure that any inefficiencies or logical errors in the code will be more apparent. The code should be able to handle this case correctly and efficiently.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
import sys

def sol(n):
    ans = []
    calls = 0

    for i in range(2, n+1):
        calls+=1
        print("? 1", i)
        sys.stdout.flush()
        node = int(input())

        p = node
        k = -1
        while p!=k:
            calls+=1
            print("?", p, i)
            k = int(input())

        a = str(p) + " " + str(i)
        ans.append(a)

    print("! "+ " ".join(ans))

t = int(input())
for _ in range(t):
    n = int(input())
    sol(n)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the given code, we need to consider edge cases and scenarios that can maximize the failure probability. The code seems to have an issue with handling trees that have a more complex structure, particularly those with multiple branches or deeper structures.

Let's consider a tree with a star-like structure, where one central node is connected to all other nodes. This structure is simple but can reveal issues in the query logic.

Here's a small-scale test input that fits the criteria:

```plaintext
1
5
```

This input represents a tree with 5 nodes. The tree can be structured as follows:
- Node 1 is the central node.
- Nodes 2, 3, 4, and 5 are all connected to node 1.

The expected structure of the tree is:
- Edges: (1, 2), (1, 3), (1, 4), (1, 5)

This input will test the code's ability to correctly identify the structure of a simple star tree. If the code fails to correctly identify the edges, it will indicate a bug in the logic.

Let's break down why this input is challenging:
- The central node (1) is connected to all other nodes, so any query involving node 1 and another node should always return node 1.
- The code should correctly identify that node 1 is the central node and all other nodes are directly connected to it.

Here is the test input:

```plaintext
1
5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
import sys

def debug(*args):
    print("DEBUG:", *args, file=sys.stderr)

t = int(input())

for _ in range(t):
    n = int(input())
    ans = []

    remaining = set(range(1, n + 1))
    doneset = set()

    qed = set()

    def done():
        return len(ans) == n - 1

    def decipher(one, two):
        if done() or (one, two) in qed:
            return
        print(f"? {one} {two}", flush=True)
        qed.add((one, two))
        qed.add((two, one))
        mid = int(input())

        for num in [one, two, mid]:
            if num in remaining:
                remaining.remove(num)
                doneset.add(num)

        if mid == one:
            ans.append([one, two])
            return

        decipher(one, mid)
        decipher(mid, two)

    started = False
    while not done():
        if not started:
            decipher(1, 2)
        else:
            a = next(iter(doneset))
            doneset.remove(a)
            b = next(iter(remaining))
            remaining.remove(b)
            decipher(a, b)
        started = True

    print("! ", end='')
    for i, j in ans:
        print(i, j, end=' ')
    print(flush=True)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            List<int[]> edges = new ArrayList<>();

            for (int i = 2; i <= n; i++) {
                System.out.println("? 1 " + i);
                System.out.flush();

                int x = sc.nextInt();

                if (x == 1) {
                    edges.add(new int[]{1, i});
                } else {
                    edges.add(new int[]{x, i});
                }
            }

            System.out.print("!");
            for (int[] edge : edges) {
                System.out.print(" " + edge[0] + " " + edge[1]);
            }
            System.out.println();
            System.out.flush();
        }

        sc.close();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, we need to consider the following:

1. **Edge Cases**: The code assumes that the first node (1) is always part of the minimum distance query responses. We need to create a tree where this assumption fails.
2. **Complex Tree Structures**: A tree with a more complex structure, such as a star or a chain, can help expose the bug.
3. **Multiple Test Cases**: Since the input can have multiple test cases, we can include a few to ensure robustness.

Let's create a test input with a star tree where node 1 is not the center, and a chain tree where node 1 is not at one of the ends. This will help expose the bug in the code.

### Test Input

```plaintext
2
4
5
```

### Explanation

1. **First Test Case (n = 4)**:
   - Tree structure: 2 - 1 - 3 - 4
   - Queries:
     - "? 1 2" should return 1 (since 1 is directly connected to 2)
     - "? 1 3" should return 1 (since 1 is directly connected to 3)
     - "? 1 4" should return 3 (since 3 is the node that minimizes the distance difference between 1 and 4)

2. **Second Test Case (n = 5)**:
   - Tree structure: 1 - 2 - 3 - 4 - 5
   - Queries:
     - "? 1 2" should return 1 (since 1 is directly connected to 2)
     - "? 1 3" should return 2 (since 2 is the node that minimizes the distance difference between 1 and 3)
     - "? 1 4" should return 3 (since 3 is the node that minimizes the distance difference between 1 and 4)
     - "? 1 5" should return 3 (since 3 is the node that minimizes the distance difference between 1 and 5)

This test input should expose the bug in the code because the code assumes that the first node (1) is always part of the minimum distance query responses, which is not always true in these tree structures.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
//package codeforces.round967div2;

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class C {
    static InputReader in;
    static PrintWriter out;

    public static void main(String[] args) {
        //initReaderPrinter(true);
        initReaderPrinter(false);
        solve(in.nextInt());
        //solve(1);
    }

    /*
        General tips
        1. It is ok to fail, but it is not ok to fail for the same mistakes over and over!
        2. Train smarter, not harder!
        3. If you find an answer and want to return immediately, don't forget to flush before return!
    */
    /*
        Read before practice
        1. Set a timer based on a problem's difficulty level: 45 minutes at your current target practice level;
        2. During a problem solving session, focus! Do not switch problems or even worse switch to do something else;
        3. If fail to solve within timer limit, read editorials to get as little help as possible to get yourself unblocked;
        4. If after reading the entire editorial and other people's code but still can not solve, move this problem to to-do list
           and re-try in the future.
        5. Keep a practice log about new thinking approaches, good tricks, bugs; Review regularly;
        6. Also try this new approach suggested by um_nik: Solve with no intention to read editorial.
           If getting stuck, skip it and solve other similar level problems.
           Wait for 1 week then try to solve again. Only read editorial after you solved a problem.
        7. Remember to also submit in the original problem link (if using gym) so that the 1 v 1 bot knows which problems I have solved already.
        8. Form the habit of writing down an implementable solution idea before coding! You've taken enough hits during contests because you
        rushed to coding!
    */
    /*
        Read before contests and lockout 1 v 1
        Mistakes you've made in the past contests:
        1. Tried to solve without going through given test examples -> wasting time on solving a different problem than asked;
        2. Rushed to coding without getting a comprehensive sketch of your solution -> implementation bugs and WA; Write down your idea step
        by step, no need to rush. It is always better to have all the steps considered before hand! Think about all the past contests that
        you have failed because slow implementation and implementation bugs! This will be greatly reduced if you take your time to get a
        thorough idea steps!
        3. Forgot about possible integer overflow;

        When stuck:
        1. Understand problem statements? Walked through test examples?
        2. Take a step back and think about other approaches?
        3. Check rank board to see if you can skip to work on a possibly easier problem?
        4. If none of the above works, take a guess?
        5. Any chance you got WA due to integer overflow, especially if you are dealing with all subarrays. The sum
           can get deceptively large! If in doubt, just use long instead of int.
    */

    static void solve(int testCnt) {
        for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            int n = in.nextInt();
            List<int[]> ans = new ArrayList<>();
            ArrayDeque<Integer> q = new ArrayDeque<>();
            for(int i = 2; i <= n; i++) {
                q.addLast(i);
            }
            Set<Integer> included = new HashSet<>();
            included.add(1);
            while(ans.size() < n - 1) {
                int curr = q.removeFirst();
                while(true) {
                    out.println("? " + 1 + " " + curr);
                    out.flush();
                    int x = in.nextInt();
                    if(included.contains(x)) {
                        ans.add(new int[]{x, curr});
                        included.add(curr);
                        break;
                    }
                    else {
                        curr = x;
                    }
                }
            }

            out.print("! ");
            for(int[] e : ans) {
                out.print(e[0] + " " + e[1] + " ");
            }
            out.println();
            out.flush();
        }
        out.close();
    }

    static long addWithMod(long x, long y, long mod) {
        return (x + y) % mod;
    }

    static long subtractWithMod(long x, long y, long mod) {
        return ((x - y) % mod + mod) % mod;
    }

    static long multiplyWithMod(long x, long y, long mod) {
        x %= mod;
        y %= mod;
        return x * y % mod;
    }

    static long modInv(long x, long mod) {
        return fastPowMod(x, mod - 2, mod);
    }

    static long fastPowMod(long x, long n, long mod) {
        if (n == 0) return 1;
        long half = fastPowMod(x, n / 2, mod);
        if (n % 2 == 0) return half * half % mod;
        return half * half % mod * x % mod;
    }

    static void initReaderPrinter(boolean test) {
        if (test) {
            try {
                in = new InputReader(new FileInputStream("input.in"));
                out = new PrintWriter(new FileOutputStream("output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        Integer[] nextIntArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        int[] nextIntArrayPrimitive(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        int[] nextIntArrayPrimitiveOneIndexed(int n) {
            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++) a[i] = nextInt();
            return a;
        }

        Long[] nextLongArray(int n) {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }

        long[] nextLongArrayPrimitive(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }

        long[] nextLongArrayPrimitiveOneIndexed(int n) {
            long[] a = new long[n + 1];
            for (int i = 1; i <= n; i++) a[i] = nextLong();
            return a;
        }

        String[] nextStringArray(int n) {
            String[] g = new String[n];
            for (int i = 0; i < n; i++) g[i] = next();
            return g;
        }

        List<Integer>[] readUnWeightedGraphOneIndexed(int n, int m) {
            List<Integer>[] adj = new List[n + 1];
            for (int i = 0; i <= n; i++) {
                adj[i] = new ArrayList<>();
            }
            for (int i = 0; i < m; i++) {
                int u = nextInt();
                int v = nextInt();
                adj[u].add(v);
                adj[v].add(u);
            }
            return adj;
        }

        List<int[]>[] readWeightedGraphOneIndexed(int n, int m) {
            List<int[]>[] adj = new List[n + 1];
            for (int i = 0; i <= n; i++) {
                adj[i] = new ArrayList<>();
            }
            for (int i = 0; i < m; i++) {
                int u = nextInt();
                int v = nextInt();
                int w = in.nextInt();
                adj[u].add(new int[]{v, w});
                adj[v].add(new int[]{u, w});
            }
            return adj;
        }

        List<Integer>[] readUnWeightedGraphZeroIndexed(int n, int m) {
            List<Integer>[] adj = new List[n];
            for (int i = 0; i < n; i++) {
                adj[i] = new ArrayList<>();
            }
            for (int i = 0; i < m; i++) {
                int u = nextInt() - 1;
                int v = nextInt() - 1;
                adj[u].add(v);
                adj[v].add(u);
            }
            return adj;
        }

        List<int[]>[] readWeightedGraphZeroIndexed(int n, int m) {
            List<int[]>[] adj = new List[n];
            for (int i = 0; i < n; i++) {
                adj[i] = new ArrayList<>();
            }
            for (int i = 0; i < m; i++) {
                int u = nextInt() - 1;
                int v = nextInt() - 1;
                int w = in.nextInt();
                adj[u].add(new int[]{v, w});
                adj[v].add(new int[]{u, w});
            }
            return adj;
        }

        /*
            A more efficient way of building an undirected graph using int[] instead of ArrayList to store each node's neighboring nodes.
            1-indexed.
         */
        int[][] buildUndirectedGraph(int nodeCnt, int edgeCnt) {
            int[] end1 = new int[edgeCnt], end2 = new int[edgeCnt];
            int[] edgeCntForEachNode = new int[nodeCnt + 1], idxForEachNode = new int[nodeCnt + 1];
            for (int i = 0; i < edgeCnt; i++) {
                int u = in.nextInt(), v = in.nextInt();
                edgeCntForEachNode[u]++;
                edgeCntForEachNode[v]++;
                end1[i] = u;
                end2[i] = v;
            }
            int[][] adj = new int[nodeCnt + 1][];
            for (int i = 1; i <= nodeCnt; i++) {
                adj[i] = new int[edgeCntForEachNode[i]];
            }
            for (int i = 0; i < edgeCnt; i++) {
                adj[end1[i]][idxForEachNode[end1[i]]] = end2[i];
                idxForEachNode[end1[i]]++;
                adj[end2[i]][idxForEachNode[end2[i]]] = end1[i];
                idxForEachNode[end2[i]]++;
            }
            return adj;
        }

        /*
            A more efficient way of building an undirected weighted graph using int[] instead of ArrayList to store each node's neighboring nodes.
            1-indexed.
        */
        int[][][] buildUndirectedWeightedGraph(int nodeCnt, int edgeCnt) {
            int[] end1 = new int[edgeCnt], end2 = new int[edgeCnt], weight = new int[edgeCnt];
            int[] edgeCntForEachNode = new int[nodeCnt + 1], idxForEachNode = new int[nodeCnt + 1];
            for (int i = 0; i < edgeCnt; i++) {
                int u = in.nextInt(), v = in.nextInt(), w = in.nextInt();
                edgeCntForEachNode[u]++;
                edgeCntForEachNode[v]++;
                end1[i] = u;
                end2[i] = v;
                weight[i] = w;
            }
            int[][][] adj = new int[nodeCnt + 1][][];
            for (int i = 1; i <= nodeCnt; i++) {
                adj[i] = new int[edgeCntForEachNode[i]][2];
            }
            for (int i = 0; i < edgeCnt; i++) {
                adj[end1[i]][idxForEachNode[end1[i]]][0] = end2[i];
                adj[end1[i]][idxForEachNode[end1[i]]][1] = weight[i];
                idxForEachNode[end1[i]]++;
                adj[end2[i]][idxForEachNode[end2[i]]][0] = end1[i];
                adj[end2[i]][idxForEachNode[end2[i]]][1] = weight[i];
                idxForEachNode[end2[i]]++;
            }
            return adj;
        }

        /*
            A more efficient way of building a directed graph using int[] instead of ArrayList to store each node's neighboring nodes.
            1-indexed.
        */
        int[][] buildDirectedGraph(int nodeCnt, int edgeCnt) {
            int[] from = new int[edgeCnt], to = new int[edgeCnt];
            int[] edgeCntForEachNode = new int[nodeCnt + 1], idxForEachNode = new int[nodeCnt + 1];
            //from u to v: u -> v
            for (int i = 0; i < edgeCnt; i++) {
                int u = in.nextInt(), v = in.nextInt();
                edgeCntForEachNode[u]++;
                from[i] = u;
                to[i] = v;
            }
            int[][] adj = new int[nodeCnt + 1][];
            for (int i = 1; i <= nodeCnt; i++) {
                adj[i] = new int[edgeCntForEachNode[i]];
            }
            for (int i = 0; i < edgeCnt; i++) {
                adj[from[i]][idxForEachNode[from[i]]] = to[i];
                idxForEachNode[from[i]]++;
            }
            return adj;
        }

        /*
            A more efficient way of building a directed weighted graph using int[] instead of ArrayList to store each node's neighboring nodes.
            1-indexed.
        */
        int[][][] buildDirectedWeightedGraph(int nodeCnt, int edgeCnt) {
            int[] from = new int[edgeCnt], to = new int[edgeCnt], weight = new int[edgeCnt];
            int[] edgeCntForEachNode = new int[nodeCnt + 1], idxForEachNode = new int[nodeCnt + 1];
            //from u to v: u -> v
            for (int i = 0; i < edgeCnt; i++) {
                int u = in.nextInt(), v = in.nextInt(), w = in.nextInt();
                edgeCntForEachNode[u]++;
                from[i] = u;
                to[i] = v;
                weight[i] = w;
            }
            int[][][] adj = new int[nodeCnt + 1][][];
            for (int i = 1; i <= nodeCnt; i++) {
                adj[i] = new int[edgeCntForEachNode[i]][2];
            }
            for (int i = 0; i < edgeCnt; i++) {
                adj[from[i]][idxForEachNode[from[i]]][0] = to[i];
                adj[from[i]][idxForEachNode[from[i]]][1] = weight[i];
                idxForEachNode[from[i]]++;
            }
            return adj;
        }
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, we need to focus on edge cases or scenarios that can highlight the issues in the algorithm. The buggy code has a few potential issues:

1. **Always querying with node 1**: The code always uses node 1 as one of the nodes in the query. This can be problematic if the tree structure is such that node 1 is not a good pivot point for all queries.

2. **Handling of cycles**: Since the code is designed to work with a tree, it should not encounter cycles. However, if the tree is structured in a way that makes it difficult to correctly determine the edges, the code might fail.

3. **Inefficient edge discovery**: The code might not efficiently discover all edges, especially if the tree is not a simple linear or star structure.

To create a test case that exposes these issues, let's consider a tree where node 1 is not a good pivot point. A good example is a tree where node 1 is a leaf node, and the rest of the tree forms a more complex structure.

### Chosen Test Case
We will use a tree with 5 nodes, where node 1 is a leaf node, and the rest of the nodes form a linear structure. This will make it difficult for the buggy code to correctly determine the edges.

```plaintext
1
5
? 1 2
? 2 3
? 3 4
? 4 5
! 1 2 2 3 3 4 4 5
```

### Explanation
- **Input:**
  - `1`: Number of test cases.
  - `5`: Number of nodes in the tree.
- **Queries:**
  - `? 1 2`: Query to find the node that minimizes the distance difference between node 1 and node 2.
  - `? 2 3`: Query to find the node that minimizes the distance difference between node 2 and node 3.
  - `? 3 4`: Query to find the node that minimizes the distance difference between node 3 and node 4.
  - `? 4 5`: Query to find the node that minimizes the distance difference between node 4 and node 5.
- **Output:**
  - `! 1 2 2 3 3 4 4 5`: The edges of the tree.

This test case is designed to expose the issue with the buggy code where it always uses node 1 as a pivot. In this tree, node 1 is a leaf, and the rest of the nodes form a linear structure. This makes it difficult for the code to correctly determine the edges if it relies solely on node 1 for queries.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define loop(n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define vi vector<ll>
#define vop vector<pair<int,int>>
int mod = 1e9+7;// 998244353
#define ld long double
#define int long long
#define ll long long
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};
string dir="RLDU";
void print(vi &v){for(auto it:v) cout<<it<<" ";}
const int N=1e3+3;
vop ans;
int dp[N][N];
void rec(int i,int j){
    if(i>j)swap(i,j);
    if(dp[i][j]!=-1)return;
    dp[i][j]=0;
    cout<<"? "<<i<<" "<<j<<endl;
    cout.flush();
    int det;
    cin>>det;
    if(det==i||det==j){
        ans.push_back({i,j});
    }
    else{
        rec(i,det);
        rec(j,det);
    }
}
void TEFA(){
    int n;
    cin>>n;
    ans.clear();
    memset(dp,-1, sizeof dp);
    for(int i=2;i<=n;i++){
        rec(1,i);
    }
    cout<<"! ";
    for(auto it:ans){
        cout<<it.first<<" "<<it.second<<" ";
    }
    cout<<endl;
    cout.flush();
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    int t = 1;
    cin >> t;
    while (t--) {
        TEFA();
//        cout << "\n";
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Guess The Tree
time_limit_ms: 2000
memory_limit_mb: 256
Description: This is an interactive problem.

Misuki has chosen a secret tree with $$$n$$$ nodes, indexed from $$$1$$$ to $$$n$$$, and asked you to guess it by using queries of the following type:

- "? a b" — Misuki will tell you which node $$$x$$$ minimizes $$$|d(a,x) - d(b,x)|$$$, where $$$d(x,y)$$$ is the distance between nodes $$$x$$$ and $$$y$$$. If more than one such node exists, Misuki will tell you the one which minimizes $$$d(a,x)$$$.

Find out the structure of Misuki's secret tree using at most $$$15n$$$ queries!

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.

Each test case consists of a single line with an integer $$$n$$$ ($$$2 \le n \le 1000$$$), the number of nodes in the tree.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.

Output: None

Examples:
input:
1
4
1
1
3
output:
? 1 2

? 1 3

? 1 4

! 1 2 1 3 3 4

Note: A tree is an undirected acyclic connected graph. A tree with $$$n$$$ nodes will always have $$$n-1$$$ edges.

In the example case, the answer to "? 1 2" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$2$$$.

The answer to "? 1 3" is $$$1$$$. This means that there is an edge between nodes $$$1$$$ and $$$3$$$.

The answer to "? 1 4" is $$$3$$$. It can be proven that this can only happen if node $$$3$$$ is connected to both node $$$1$$$ and $$$4$$$.

The edges of the tree are hence $$$(1,2)$$$, $$$(1,3)$$$ and $$$(3,4)$$$.

Buggy Code:
#include <bits/stdc++.h>
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define rep(i, n) for (int i = 0; i < n; i++)
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define int long long
#define endl "\n"
#define F first
#define ALL(a) (a).begin(), (a).end()
#define S second
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> msii;
int mod = 1000000007;
int dp[1005][1005];
vector<pair<int, int>> ans;
int sz;
void recur(int x, int y)
{
    if (dp[x][y] != -1)
        return;
    cout << "? " << x << " " << y << endl;
    cout.flush();
    int mid;
    cin >> mid;
    if (x == mid)
    {
        dp[x][y] = 1;
        ans.push_back({x, y});
        return;
    }
    recur(x, mid);
    recur(mid, y);
}
void solve()
{
    int n;
    cin >> n;
    sz = n;
    memset(dp, -1, sizeof(dp));
    ans.clear();
    for (int i = 2; i <= n; i++)
    {
        recur(1, i);
    }
    cout << "!" << " ";
    for (auto i : ans)
    {
        cout << i.first << " " << i.second << " ";
    }
    cout << endl;
    cout.flush();
}
int32_t main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {

        solve();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To create a challenging test input that exposes the bug in the provided code, we need to consider the following aspects:

1. **Edge Cases**: The code should handle edge cases such as a tree with a linear structure (a chain) or a tree with a central node (a star).
2. **Complex Structures**: The code should also handle more complex structures, such as a tree with multiple branches.
3. **Query Limit**: The code should not exceed the query limit of \(15n\).

### Analyzing the Buggy Code
The provided code uses a recursive approach to find the edges of the tree. It queries the midpoint between two nodes and then recursively explores the paths from the midpoint to the original nodes. However, this approach can fail in certain cases, especially when the tree has a more complex structure.

### Challenging Test Input
Let's create a test input for a tree with a central node (a star) and a tree with a more complex structure (a tree with multiple branches).

### Test Case 1: Star Tree
A star tree with 5 nodes, where node 1 is the center and all other nodes are connected to it.
```plaintext
1
5
```

### Test Case 2: Complex Tree
A more complex tree with 7 nodes, where node 1 is connected to nodes 2 and 3, node 2 is connected to nodes 4 and 5, and node 3 is connected to nodes 6 and 7.
```plaintext
1
7
```

### Combined Test Input
Combining both test cases to ensure the code handles both simple and complex structures:
```plaintext
2
5
7
```

### Explanation
- **Star Tree**: The star tree with 5 nodes is a simple case where the central node is connected to all other nodes. The code should be able to handle this case, but it will help in verifying if the code can correctly identify the central node.
- **Complex Tree**: The tree with 7 nodes and multiple branches is a more challenging case. The code should be able to correctly identify the structure of the tree, but it may fail if it does not handle the recursive queries correctly.

This test input will help in exposing any bugs in the code, especially in handling more complex tree structures.