**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Ruler (easy version)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This is the easy version of the problem. The only difference between the two versions is that in this version, you can make at most $$$\mathbf{10}$$$ queries.

This is an interactive problem. If you are unsure how interactive problems work, then it is recommended to read the guide for participants.

We have a secret ruler that is missing one number $$$x$$$ ($$$2 \leq x \leq 999$$$). When you measure an object of length $$$y$$$, the ruler reports the following values:

- If $$$y < x$$$, the ruler (correctly) measures the object as having length $$$y$$$.
- If $$$y \geq x$$$, the ruler incorrectly measures the object as having length $$$y+1$$$.

The ruler above is missing the number $$$4$$$, so it correctly measures the first segment as length $$$3$$$ but incorrectly measures the second segment as length $$$6$$$ even though it is actually $$$5$$$.

You need to find the value of $$$x$$$. To do that, you can make queries of the following form:

- $$$\texttt{?}~a~b$$$ — in response, we will measure the side lengths of an $$$a \times b$$$ rectangle with our ruler and multiply the results, reporting the measured area of the rectangle back to you. For example, if $$$x=4$$$ and you query a $$$3 \times 5$$$ rectangle, we will measure its side lengths as $$$3 \times 6$$$ and report $$$18$$$ back to you.

Find the value of $$$x$$$. You can ask at most $$$\mathbf{10}$$$ queries.

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

Output: None

Examples:
input:
2

18

25

9999
output:
? 3 5

? 4 4

! 4
? 99 100

! 100

Note: In the first test, the interaction proceeds as follows.

SolutionJuryExplanation$$$\texttt{2}$$$There are 2 test cases.$$$\texttt{? 3 5}$$$$$$\texttt{18}$$$Secretly, the jury picked $$$x=4$$$. The solution requests the $$$3 \times 5$$$ rectangle, and the jury responds with $$$3 \times 6 = 18$$$, as described in the statement.$$$\texttt{? 4 4}$$$$$$\texttt{25}$$$The solution requests the $$$4 \times 4$$$ rectangle, which the jury measures as $$$5 \times 5$$$ and responds with $$$25$$$.$$$\texttt{! 4}$$$The solution has somehow determined that $$$x=4$$$, and outputs it. Since the output is correct, the jury continues to the next test case.$$$\texttt{? 99 100}$$$$$$\texttt{1}$$$Secretly, the jury picked $$$x=100$$$. The solution requests the $$$99 \times 100$$$ rectangle, which the jury measures as $$$99 \times 101$$$ and responds with $$$9999$$$.$$$\texttt{! 100}$$$The solution has somehow determined that $$$x=100$$$, and outputs it. Since the output is correct and there are no more test cases, the jury and the solution exit.

Note that the line breaks in the example input and output are for the sake of clarity, and do not occur in the real interaction.

Buggy Code:
from math import floor
from sys import stdout

for _ in range(int(input())):
    a = 2
    b = 999
    flag = 0
    while flag == 0:
        aa = floor((a+b)/2)
        # print(a,b,aa)
        print("?", aa,aa+1)
        stdout.flush()
        bb = int(input())
        if b-a==1:
            flag = 1
            if bb == (aa+1)*(aa+2):
                print("!", a)
            else:
                print("!", b)
            stdout.flush()
            continue
        elif bb == aa*(aa+1):
            a = aa+2
        elif bb == (aa+1)*(aa+2):
            b = aa
        elif bb == aa*(aa+2):
            flag = 1
            print("!", aa+1)
            stdout.flush()

**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
2

18

25
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Ruler (easy version)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This is the easy version of the problem. The only difference between the two versions is that in this version, you can make at most $$$\mathbf{10}$$$ queries.

This is an interactive problem. If you are unsure how interactive problems work, then it is recommended to read the guide for participants.

We have a secret ruler that is missing one number $$$x$$$ ($$$2 \leq x \leq 999$$$). When you measure an object of length $$$y$$$, the ruler reports the following values:

- If $$$y < x$$$, the ruler (correctly) measures the object as having length $$$y$$$.
- If $$$y \geq x$$$, the ruler incorrectly measures the object as having length $$$y+1$$$.

The ruler above is missing the number $$$4$$$, so it correctly measures the first segment as length $$$3$$$ but incorrectly measures the second segment as length $$$6$$$ even though it is actually $$$5$$$.

You need to find the value of $$$x$$$. To do that, you can make queries of the following form:

- $$$\texttt{?}~a~b$$$ — in response, we will measure the side lengths of an $$$a \times b$$$ rectangle with our ruler and multiply the results, reporting the measured area of the rectangle back to you. For example, if $$$x=4$$$ and you query a $$$3 \times 5$$$ rectangle, we will measure its side lengths as $$$3 \times 6$$$ and report $$$18$$$ back to you.

Find the value of $$$x$$$. You can ask at most $$$\mathbf{10}$$$ queries.

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

Output: None

Examples:
input:
2

18

25

9999
output:
? 3 5

? 4 4

! 4
? 99 100

! 100

Note: In the first test, the interaction proceeds as follows.

SolutionJuryExplanation$$$\texttt{2}$$$There are 2 test cases.$$$\texttt{? 3 5}$$$$$$\texttt{18}$$$Secretly, the jury picked $$$x=4$$$. The solution requests the $$$3 \times 5$$$ rectangle, and the jury responds with $$$3 \times 6 = 18$$$, as described in the statement.$$$\texttt{? 4 4}$$$$$$\texttt{25}$$$The solution requests the $$$4 \times 4$$$ rectangle, which the jury measures as $$$5 \times 5$$$ and responds with $$$25$$$.$$$\texttt{! 4}$$$The solution has somehow determined that $$$x=4$$$, and outputs it. Since the output is correct, the jury continues to the next test case.$$$\texttt{? 99 100}$$$$$$\texttt{1}$$$Secretly, the jury picked $$$x=100$$$. The solution requests the $$$99 \times 100$$$ rectangle, which the jury measures as $$$99 \times 101$$$ and responds with $$$9999$$$.$$$\texttt{! 100}$$$The solution has somehow determined that $$$x=100$$$, and outputs it. Since the output is correct and there are no more test cases, the jury and the solution exit.

Note that the line breaks in the example input and output are for the sake of clarity, and do not occur in the real interaction.

Buggy Code:
from sys import stdin

class FastIO:
    def __init__(self):
        self.random_seed = 0
        self.flush = False
        self.inf = 1 << 32
        self.dire4 = [(0, -1), (0, 1), (1, 0), (-1, 0)]
        self.dire8 = [(0, -1), (0, 1), (1, 0), (-1, 0)] + [(1, -1), (1, 1), (-1, -1), (-1, 1)]
        return

    @staticmethod
    def read_int():
        return int(stdin.readline().rstrip())

    @staticmethod
    def read_float():
        return float(stdin.readline().rstrip())

    @staticmethod
    def read_list_ints():
        return list(map(int, stdin.readline().rstrip().split()))

    @staticmethod
    def read_list_ints_minus_one():
        return list(map(lambda x: int(x) - 1, stdin.readline().rstrip().split()))

    @staticmethod
    def read_str():
        return stdin.readline().rstrip()

    @staticmethod
    def read_list_strs():
        return stdin.readline().rstrip().split()

    def get_random_seed(self):
        import random
        self.random_seed = random.randint(0, 10 ** 9 + 7)
        return

    def st(self, x):
        return print(x, flush=self.flush)

    def yes(self, s=None):
        self.st("Yes" if not s else s)
        return

    def no(self, s=None):
        self.st("No" if not s else s)
        return

    def lst(self, x):
        return print(*x, flush=self.flush)

    def flatten(self, lst):
        self.st("\n".join(str(x) for x in lst))
        return

    @staticmethod
    def max(a, b):
        return a if a > b else b

    @staticmethod
    def min(a, b):
        return a if a < b else b

    @staticmethod
    def ceil(a, b):
        return a // b + int(a % b != 0)

    @staticmethod
    def accumulate(nums):
        n = len(nums)
        pre = [0] * (n + 1)
        for i in range(n):
            pre[i + 1] = pre[i] + nums[i]
        return pre

class Solution:
    def __init__(self):
        return

    @staticmethod
    def main(ac=FastIO()):
        """
        url: url of the problem
        tag: ternary_search|interactive|classical
        """
        ac.flush = True
        for _ in range(ac.read_int()):
            left = 2
            right = 1000
            while left < right - 1:
                diff = (right - left) // 3
                mid1 = left + diff
                mid2 = left + 2 * diff
                ac.lst(["?", mid1, mid2])
                res = ac.read_int()
                if res == mid1 * mid2:
                    left = mid2 + 1
                elif res == mid1 * (mid2 + 1):
                    left = mid1 + 1
                    right = mid2
                else:
                    right = mid1 - 1
            if left < right:
                ac.lst(["?", left, left])
                if ac.read_int() == left * left:
                    ac.lst(["!", right])
                else:
                    ac.lst(["!", left])
            else:
                ac.lst(["!", left])
        return

Solution().main()

**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 edge cases and scenarios that can cause the code to fail. Here are the steps to think through the problem:

1. **Understand the Buggy Code**:
   - The code uses a ternary search to narrow down the possible values of `x`.
   - It queries the ruler with specific values and adjusts the search range based on the response.

2. **Identify Potential Bugs**:
   - The code might have issues with edge cases, especially when the search range is very small.
   - The logic for updating the search range might be incorrect, leading to incorrect values being queried.

3. **Generate Test Cases**:
   - Test cases should include values of `x` that are at the boundaries of the search range.
   - Test cases should also include values of `x` that are in the middle of the search range to ensure the logic for updating the search range is correct.

4. **Create a Small-Scale Test Input**:
   - The test input should be small enough to be manageable but large enough to cover different scenarios.

Given these considerations, a challenging test input could be:

```plaintext
3

18

25

9999
```

This test input includes:
- A case where `x = 4` (the first test case).
- A case where `x = 100` (the second test case).
- A case where `x = 999` (the third test case).

These values are chosen to test the boundaries and the middle of the search range. Here is the test input:

```plaintext
3

18

25

9999
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Ruler (easy version)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This is the easy version of the problem. The only difference between the two versions is that in this version, you can make at most $$$\mathbf{10}$$$ queries.

This is an interactive problem. If you are unsure how interactive problems work, then it is recommended to read the guide for participants.

We have a secret ruler that is missing one number $$$x$$$ ($$$2 \leq x \leq 999$$$). When you measure an object of length $$$y$$$, the ruler reports the following values:

- If $$$y < x$$$, the ruler (correctly) measures the object as having length $$$y$$$.
- If $$$y \geq x$$$, the ruler incorrectly measures the object as having length $$$y+1$$$.

The ruler above is missing the number $$$4$$$, so it correctly measures the first segment as length $$$3$$$ but incorrectly measures the second segment as length $$$6$$$ even though it is actually $$$5$$$.

You need to find the value of $$$x$$$. To do that, you can make queries of the following form:

- $$$\texttt{?}~a~b$$$ — in response, we will measure the side lengths of an $$$a \times b$$$ rectangle with our ruler and multiply the results, reporting the measured area of the rectangle back to you. For example, if $$$x=4$$$ and you query a $$$3 \times 5$$$ rectangle, we will measure its side lengths as $$$3 \times 6$$$ and report $$$18$$$ back to you.

Find the value of $$$x$$$. You can ask at most $$$\mathbf{10}$$$ queries.

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

Output: None

Examples:
input:
2

18

25

9999
output:
? 3 5

? 4 4

! 4
? 99 100

! 100

Note: In the first test, the interaction proceeds as follows.

SolutionJuryExplanation$$$\texttt{2}$$$There are 2 test cases.$$$\texttt{? 3 5}$$$$$$\texttt{18}$$$Secretly, the jury picked $$$x=4$$$. The solution requests the $$$3 \times 5$$$ rectangle, and the jury responds with $$$3 \times 6 = 18$$$, as described in the statement.$$$\texttt{? 4 4}$$$$$$\texttt{25}$$$The solution requests the $$$4 \times 4$$$ rectangle, which the jury measures as $$$5 \times 5$$$ and responds with $$$25$$$.$$$\texttt{! 4}$$$The solution has somehow determined that $$$x=4$$$, and outputs it. Since the output is correct, the jury continues to the next test case.$$$\texttt{? 99 100}$$$$$$\texttt{1}$$$Secretly, the jury picked $$$x=100$$$. The solution requests the $$$99 \times 100$$$ rectangle, which the jury measures as $$$99 \times 101$$$ and responds with $$$9999$$$.$$$\texttt{! 100}$$$The solution has somehow determined that $$$x=100$$$, and outputs it. Since the output is correct and there are no more test cases, the jury and the solution exit.

Note that the line breaks in the example input and output are for the sake of clarity, and do not occur in the real interaction.

Buggy Code:
import java.util.Scanner;

public class g {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
//        while (t-- > 0){
//            int l = 1;
//            int r = 1000;
//            while(l < r){
//                int mid1 = (2 * l + r) / 3;
//                int mid2 = (2 * r + l) / 3;
//                System.out.println("? " + mid1 + " " + mid2);
//                int x = sc.nextInt();
//                if(x == (mid1 + 1) * (mid2 + 1)){
//                    r = mid1;
//                }
//                else if(x == (mid1) * (mid2 + 1)){
//                    l = mid1 + 1;
//                    r = mid2;
//                }
//                else{
//                    l = mid2 + 1;
//                }
//            }
//            System.out.println("! " + l);
//        }
        while (t-- > 0){
            int l = 2;
            int r = 999;
            while(r - l > 1){
                int mid = (l + r) / 2;
                System.out.println("? " + mid + " " + mid);
                int x = sc.nextInt();
                if(x != mid * mid){
                    r = mid;
                } else l = mid + 1;
            }
            System.out.println("! " + l);
        }
    }
}

**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
3

16

25

49
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Ruler (easy version)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This is the easy version of the problem. The only difference between the two versions is that in this version, you can make at most $$$\mathbf{10}$$$ queries.

This is an interactive problem. If you are unsure how interactive problems work, then it is recommended to read the guide for participants.

We have a secret ruler that is missing one number $$$x$$$ ($$$2 \leq x \leq 999$$$). When you measure an object of length $$$y$$$, the ruler reports the following values:

- If $$$y < x$$$, the ruler (correctly) measures the object as having length $$$y$$$.
- If $$$y \geq x$$$, the ruler incorrectly measures the object as having length $$$y+1$$$.

The ruler above is missing the number $$$4$$$, so it correctly measures the first segment as length $$$3$$$ but incorrectly measures the second segment as length $$$6$$$ even though it is actually $$$5$$$.

You need to find the value of $$$x$$$. To do that, you can make queries of the following form:

- $$$\texttt{?}~a~b$$$ — in response, we will measure the side lengths of an $$$a \times b$$$ rectangle with our ruler and multiply the results, reporting the measured area of the rectangle back to you. For example, if $$$x=4$$$ and you query a $$$3 \times 5$$$ rectangle, we will measure its side lengths as $$$3 \times 6$$$ and report $$$18$$$ back to you.

Find the value of $$$x$$$. You can ask at most $$$\mathbf{10}$$$ queries.

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

Output: None

Examples:
input:
2

18

25

9999
output:
? 3 5

? 4 4

! 4
? 99 100

! 100

Note: In the first test, the interaction proceeds as follows.

SolutionJuryExplanation$$$\texttt{2}$$$There are 2 test cases.$$$\texttt{? 3 5}$$$$$$\texttt{18}$$$Secretly, the jury picked $$$x=4$$$. The solution requests the $$$3 \times 5$$$ rectangle, and the jury responds with $$$3 \times 6 = 18$$$, as described in the statement.$$$\texttt{? 4 4}$$$$$$\texttt{25}$$$The solution requests the $$$4 \times 4$$$ rectangle, which the jury measures as $$$5 \times 5$$$ and responds with $$$25$$$.$$$\texttt{! 4}$$$The solution has somehow determined that $$$x=4$$$, and outputs it. Since the output is correct, the jury continues to the next test case.$$$\texttt{? 99 100}$$$$$$\texttt{1}$$$Secretly, the jury picked $$$x=100$$$. The solution requests the $$$99 \times 100$$$ rectangle, which the jury measures as $$$99 \times 101$$$ and responds with $$$9999$$$.$$$\texttt{! 100}$$$The solution has somehow determined that $$$x=100$$$, and outputs it. Since the output is correct and there are no more test cases, the jury and the solution exit.

Note that the line breaks in the example input and output are for the sake of clarity, and do not occur in the real interaction.

Buggy Code:
import java.io.*;
import java.util.*;

public class alpha{
    static FastReader sc = new FastReader();
    static StringBuilder print ;
    public static void main (String[] args) throws java.lang.Exception{
        int num = sc.nextInt();
        while(num-->0){
            print = new StringBuilder();
            solve();
            System.out.println(print);
        }
    }

    private static void solve(int[] arr) {

    }

    private static void solve() {
        int low = 0;
        int high =1000;
        int ans =-1;
        while(low<high){
            int mid = (low+high)/2;
            System.out.println("? "+mid+" "+mid);
            int area = sc.nextInt();
            System.out.flush();
            if(mid*mid==area){
                low = mid+1;
            }else{
                ans =mid;
                high =mid-1;
            }

        }
        print.append("! "+ans);

    }

    private static void input(int[] arr) {
        int n = arr.length;
        for(int i =0 ; i< n;i++){
            arr[i] = sc.nextInt();
        }
    }
}

//--------------------------------------------------------------------------------------

class pair implements Comparable<pair>{
    int x;
    int y;
    pair(int i,int j){
        x=i;
        y=j;
    }
    public boolean equals(Object o) {
        if (o instanceof pair) {
            pair p = (pair)o;
            return p.x == x && p.y == y;
        }
        return false;
    }
    public int hashCode() {
        return Integer.valueOf(x).hashCode() * 31 + Integer.valueOf(y).hashCode();

    }
    // @Override
    public int compareTo(pair p) {
        int a = Integer.compare(x, p.x);
        if(a==0){
            return Integer.compare(y, p.y);
        }
        return a;
    }
}
//=============================================================================

class FastReader{
    BufferedReader br;
    StringTokenizer st;
    public FastReader(){
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }
    String next(){
        while (st == null || !st.hasMoreElements()){
            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;
    }
}

**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 where the algorithm might fail. The code uses a binary search approach to find the missing number \( x \). However, there are a few key issues:

1. **Incorrect Binary Search Logic**: The code incorrectly updates the `low` and `high` pointers, which can lead to incorrect results.
2. **Handling of Edge Cases**: The code does not handle edge cases well, such as when \( x \) is very close to the boundaries (2 or 999).

Let's consider the following test input to expose these issues:

```plaintext
3

16

25

9999
```

### Explanation:

1. **Test Case 1: \( x = 4 \)**
   - The code will query \( ? 2 2 \) and receive \( 4 \) (correct).
   - It will then query \( ? 3 3 \) and receive \( 9 \) (correct).
   - It will then query \( ? 4 4 \) and receive \( 25 \) (incorrect, should be 16).
   - The code should identify \( x = 4 \).

2. **Test Case 2: \( x = 5 \)**
   - The code will query \( ? 2 2 \) and receive \( 4 \) (correct).
   - It will then query \( ? 3 3 \) and receive \( 9 \) (correct).
   - It will then query \( ? 4 4 \) and receive \( 16 \) (correct).
   - It will then query \( ? 5 5 \) and receive \( 36 \) (incorrect, should be 25).
   - The code should identify \( x = 5 \).

3. **Test Case 3: \( x = 100 \)**
   - The code will query \( ? 99 99 \) and receive \( 99 \times 100 = 9900 \) (correct).
   - It will then query \( ? 100 100 \) and receive \( 101 \times 101 = 10201 \) (incorrect, should be 10000).
   - The code should identify \( x = 100 \).

This test input is designed to cover a range of scenarios, including the middle of the range, a small value, and a large value. It should help expose the bugs in the binary search logic and the handling of edge cases.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Darius' Wisdom
time_limit_ms: 2000
memory_limit_mb: 256
Description: Darius the Great is constructing $$$n$$$ stone columns, each consisting of a base and between $$$0$$$, $$$1$$$, or $$$2$$$ inscription pieces stacked on top.

In each move, Darius can choose two columns $$$u$$$ and $$$v$$$ such that the difference in the number of inscriptions between these columns is exactly $$$1$$$, and transfer one inscription from the column with more inscriptions to the other one. It is guaranteed that at least one column contains exactly $$$1$$$ inscription.

Since beauty is the main pillar of historical buildings, Darius wants the columns to have ascending heights. To avoid excessive workers' efforts, he asks you to plan a sequence of at most $$$n$$$ moves to arrange the columns in non-decreasing order based on the number of inscriptions. Minimizing the number of moves is not required.

Input: The first line contains an integer $$$t$$$ — the number of test cases. ($$$1 \leq t \leq 3000$$$)

The first line of each test case contains an integer $$$n$$$ — the number of stone columns. ($$$1 \leq n \leq 2 \cdot 10^5$$$)

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i \in \{0,1,2\}$$$ represents the initial number of inscriptions in the $$$i$$$-th column. It is guaranteed that at least one column has exactly $$$1$$$ inscription.

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

Output: For each test case, output an integer $$$k$$$ — the number of moves used to sort the columns. ($$$0 \leq k \leq n$$$)

Then, output $$$k$$$ lines, each containing two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$), representing the indices of the columns involved in the $$$i$$$-th move. During each move, it must hold that $$$|a_{u_i} - a_{v_i}| = 1$$$, and one inscription is transferred from the column with more inscriptions to the other.

It can be proven that a valid solution always exists under the given constraints.

Examples:
input:
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
output:
2
2 4
2 3
2
3 1
2 3
0

Note: Columns state in the first test case:

- Initial: $$$0, 2, 0, 1$$$
- After the first move: $$$0, 1, 0, 2$$$
- After the second move: $$$0, 0, 1, 2$$$

Columns state in the second test case:

- Initial: $$$1, 2, 0$$$
- After the first move: $$$0, 2, 1$$$
- After the second move: $$$0, 1, 2$$$

In the third test case, the column heights are already sorted in ascending order.

Buggy Code:
#include <cstdio>
#include <cstring>

const int   SIZE    = 200001;
int         n_TotCase;
int         n_Step;
int         n_Temp;
int         n_CurPos;
int         n_TotColumn;
int         n_Height[SIZE];
int         n_StepAns[SIZE][2];
int         n_Cnt[3];
int         n_PosNote[3][SIZE];

int main()
{
    scanf("%d", &n_TotCase);

    while (n_TotCase--)
    {
        memset(n_Cnt, 0, sizeof(n_Cnt));

        scanf("%d", &n_TotColumn);

        for (int i = 1; i <= n_TotColumn; i++)
        {
            scanf("%d", &n_Height[i]);

            n_PosNote[n_Height[i]][n_Cnt[n_Height[i]]]  = i;
            n_Cnt[n_Height[i]]++;
        }

        n_Step      = 0;
        n_CurPos    = n_TotColumn;

        for (int i = 0; i < n_Cnt[2]; i++)
        {
            switch(n_Height[n_CurPos - i])
            {
                case 2:
                {
                    break;
                }
                case 1:
                {
                    n_StepAns[n_Step][0]                = n_PosNote[2][n_Cnt[2] - 1];
                    n_StepAns[n_Step][1]                = n_CurPos - i;
                    n_PosNote[1][n_Cnt[1] - 1]          = n_StepAns[n_Step][0];
                    n_PosNote[2][n_Cnt[2] - i - 1]      = n_StepAns[n_Step][1];
                    n_Height[n_StepAns[n_Step][0]]      = 1;
                    n_Height[n_StepAns[n_Step][1]]      = 2;
                    n_Step++;
                    break;
                }
                case 0:
                {
                    n_StepAns[n_Step][0]                = n_PosNote[1][n_Cnt[1] - 1];
                    n_StepAns[n_Step][1]                = n_CurPos - i;
                    n_PosNote[0][n_Cnt[0] - 1]          = n_StepAns[n_Step][0];
                    n_PosNote[1][n_Cnt[1] - 1]          = n_StepAns[n_Step][1];
                    n_Height[n_StepAns[n_Step][0]]      = 0;
                    n_Height[n_StepAns[n_Step][1]]      = 1;
                    n_Step++;
                    n_StepAns[n_Step][0]                = n_PosNote[2][n_Cnt[2] - 1];
                    n_StepAns[n_Step][1]                = n_CurPos - i;
                    n_PosNote[1][n_Cnt[1] - 1]          = n_StepAns[n_Step][0];
                    n_PosNote[2][n_Cnt[2] - i - 1]      = n_StepAns[n_Step][1];
                    n_Height[n_StepAns[n_Step][0]]      = 1;
                    n_Height[n_StepAns[n_Step][1]]      = 2;
                    n_Step++;
                    break;
                }
                default:
                {
                    break;
                }
            }
        }

        n_CurPos    -= n_Cnt[2];

        for (int i = 0; i < n_Cnt[1]; i++)
        {
            if (!n_Height[n_CurPos - i])
            {
                n_StepAns[n_Step][0]                = n_PosNote[1][n_Cnt[1] - i - 1];
                n_StepAns[n_Step][1]                = n_CurPos - i;
                n_PosNote[0][n_Cnt[0] - 1]          = n_StepAns[n_Step][0];
                n_PosNote[1][n_Cnt[1] - i - 1]      = n_StepAns[n_Step][1];
                n_Height[n_StepAns[n_Step][0]]      = 0;
                n_Height[n_StepAns[n_Step][1]]      = 1;
                n_Step++;
            }
        }

        printf("%d\n", n_Step);

        for (int i = 0; i < n_Step; i++)
        {
            printf("%d %d\n", n_StepAns[i][0], n_StepAns[i][1]);
        }
    }

    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
3
4
0 2 0 1
3
1 2 0
5
2 2 2 0 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Darius' Wisdom
time_limit_ms: 2000
memory_limit_mb: 256
Description: Darius the Great is constructing $$$n$$$ stone columns, each consisting of a base and between $$$0$$$, $$$1$$$, or $$$2$$$ inscription pieces stacked on top.

In each move, Darius can choose two columns $$$u$$$ and $$$v$$$ such that the difference in the number of inscriptions between these columns is exactly $$$1$$$, and transfer one inscription from the column with more inscriptions to the other one. It is guaranteed that at least one column contains exactly $$$1$$$ inscription.

Since beauty is the main pillar of historical buildings, Darius wants the columns to have ascending heights. To avoid excessive workers' efforts, he asks you to plan a sequence of at most $$$n$$$ moves to arrange the columns in non-decreasing order based on the number of inscriptions. Minimizing the number of moves is not required.

Input: The first line contains an integer $$$t$$$ — the number of test cases. ($$$1 \leq t \leq 3000$$$)

The first line of each test case contains an integer $$$n$$$ — the number of stone columns. ($$$1 \leq n \leq 2 \cdot 10^5$$$)

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i \in \{0,1,2\}$$$ represents the initial number of inscriptions in the $$$i$$$-th column. It is guaranteed that at least one column has exactly $$$1$$$ inscription.

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

Output: For each test case, output an integer $$$k$$$ — the number of moves used to sort the columns. ($$$0 \leq k \leq n$$$)

Then, output $$$k$$$ lines, each containing two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$), representing the indices of the columns involved in the $$$i$$$-th move. During each move, it must hold that $$$|a_{u_i} - a_{v_i}| = 1$$$, and one inscription is transferred from the column with more inscriptions to the other.

It can be proven that a valid solution always exists under the given constraints.

Examples:
input:
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
output:
2
2 4
2 3
2
3 1
2 3
0

Note: Columns state in the first test case:

- Initial: $$$0, 2, 0, 1$$$
- After the first move: $$$0, 1, 0, 2$$$
- After the second move: $$$0, 0, 1, 2$$$

Columns state in the second test case:

- Initial: $$$1, 2, 0$$$
- After the first move: $$$0, 2, 1$$$
- After the second move: $$$0, 1, 2$$$

In the third test case, the column heights are already sorted in ascending order.

Buggy Code:
#include <iostream>
#include <vector>
#include <set>
using namespace std;
vector <int> a(200005);
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;

        int p = 0, q = 0, r = 0;

        for (int i = 0; i < n; i++) {
            cin >> a[i];
            if (a[i] == 0) p++;
            else if (a[i] == 1) q++;
            else r++;
        }

        vector<int> b(n);
        for (int i = 0; i < p; i++) b[i] = 0;
        for (int i = p; i < p + q; i++) b[i] = 1;
        for (int i = p + q; i < p + q + r; i++) b[i] = 2;

        set<int> s01, s02, s10, s11, s12, s20, s21;

        for (int i = 0; i < n; i++) {
            int x = a[i], y = b[i];

            if (x == 0 && y == 1) s01.insert(i);
            if (x == 0 && y == 2) s02.insert(i);
            if (x == 1 && y == 0) s10.insert(i);
            if (x == 1 && y == 1) s11.insert(i);
            if (x == 1 && y == 2) s12.insert(i);
            if (x == 2 && y == 0) s20.insert(i);
            if (x == 2 && y == 1) s21.insert(i);

        }

        vector<pair<int, int>> ans;

        while (!s02.empty()) {
            if (!s10.empty()) {
                int p = *s02.begin();
                int q = *s10.begin();
                ans.push_back({p + 1, q + 1});
                s02.erase(s02.begin());
                s10.erase(s10.begin());
                s12.insert(p);

            } else if (!s11.empty()) {
                int p = *s02.begin();
                int q = *s11.begin();
                ans.push_back({p + 1, q + 1});
                s02.erase(s02.begin());
                s11.erase(s11.begin());
                s12.insert(p);
                s01.insert(q);
            }
        }

        while (!s20.empty()) {
    if (!s12.empty()) {
        int p = *s20.begin();
        int q = *s12.begin();
        ans.push_back({p + 1, q + 1});
        s20.erase(s20.begin());
        s12.erase(s12.begin());
        s10.insert(p);

    } else if (!s11.empty()) {
        int p = *s20.begin();
        int q = *s21.begin();
        ans.push_back({p + 1, q + 1});
        s20.erase(s20.begin());
        s11.erase(s11.begin());
        s10.insert(p);
        s21.insert(q);
    }
}

        while (!s01.empty()) {
            if (!s10.empty()) {
                int p = *s01.begin();
                int q = *s10.begin();
                ans.push_back({p + 1, q + 1});
                s01.erase(s01.begin());
                s10.erase(s10.begin());

            }  else {
                break;
            }

        }

        while (!s21.empty()) {
    if (!s12.empty()) {
        int p = *s21.begin();
        int q = *s12.begin();
        ans.push_back({p + 1, q + 1});
        s21.erase(s21.begin());
        s12.erase(s12.begin());
    } else {
        break;
    }
}

        while (!s01.empty()) {
            int p = *s01.begin();
            int q = *s12.begin();
            int r = *s20.begin();
            ans.push_back({q + 1, r + 1});
            ans.push_back({r + 1, p + 1});
            s01.erase(s01.begin());
            s12.erase(s12.begin());
            s20.erase(s20.begin());

        }

        while (!s21.empty()) {
    int p = *s21.begin();
    int q = *s10.begin();
    int r = *s02.begin();
    ans.push_back({q + 1, r + 1});
    ans.push_back({r + 1, p + 1});
    s21.erase(s21.begin());
    s10.erase(s10.begin());
    s02.erase(s02.begin());
}

        cout << ans.size() << endl;
        for (const auto &p : ans) {
            cout << p.first << " " << p.second << endl;
        }
    }
    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 code, we need to focus on edge cases that might cause the code to fail. Here are the steps to think through this:

1. **Understand the Code Logic**:
   - The code sorts the columns by moving inscriptions between columns with a difference of 1 in the number of inscriptions.
   - It uses sets to track the indices of columns with specific initial and target states.
   - The main issue might arise from the way the code handles the transfer of inscriptions, especially when dealing with multiple columns having the same number of inscriptions.

2. **Identify Potential Edge Cases**:
   - **Single Column with Inscriptions**: This should be trivial and should not cause issues.
   - **All Columns with 0 Inscriptions**: This is impossible due to the constraint that at least one column has exactly 1 inscription.
   - **All Columns with 1 Inscription**: This should be trivial as the columns are already sorted.
   - **Alternating Inscriptions**: Columns with alternating 0, 1, and 2 inscriptions can create complex transfer scenarios.
   - **Multiple Columns with the Same Inscriptions**: This can lead to incorrect transfers if the code does not handle multiple columns correctly.

3. **Generate a Challenging Test Input**:
   - A test case with multiple columns having the same inscriptions and a few columns with different inscriptions can expose issues in the transfer logic.
   - Ensure the test case is small enough to be manageable but large enough to cause issues.

Given these considerations, a challenging test input could be:

```plaintext
1
5
2 2 1 0 0
```

### Explanation:
- **Initial State**: `2 2 1 0 0`
- **Expected Final State**: `0 0 1 2 2`
- **Challenges**:
  - The code needs to handle multiple columns with 2 inscriptions.
  - The code needs to correctly transfer inscriptions to sort the columns.

This input should be challenging enough to expose any issues in the transfer logic, especially when dealing with multiple columns having the same number of inscriptions.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Darius' Wisdom
time_limit_ms: 2000
memory_limit_mb: 256
Description: Darius the Great is constructing $$$n$$$ stone columns, each consisting of a base and between $$$0$$$, $$$1$$$, or $$$2$$$ inscription pieces stacked on top.

In each move, Darius can choose two columns $$$u$$$ and $$$v$$$ such that the difference in the number of inscriptions between these columns is exactly $$$1$$$, and transfer one inscription from the column with more inscriptions to the other one. It is guaranteed that at least one column contains exactly $$$1$$$ inscription.

Since beauty is the main pillar of historical buildings, Darius wants the columns to have ascending heights. To avoid excessive workers' efforts, he asks you to plan a sequence of at most $$$n$$$ moves to arrange the columns in non-decreasing order based on the number of inscriptions. Minimizing the number of moves is not required.

Input: The first line contains an integer $$$t$$$ — the number of test cases. ($$$1 \leq t \leq 3000$$$)

The first line of each test case contains an integer $$$n$$$ — the number of stone columns. ($$$1 \leq n \leq 2 \cdot 10^5$$$)

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i \in \{0,1,2\}$$$ represents the initial number of inscriptions in the $$$i$$$-th column. It is guaranteed that at least one column has exactly $$$1$$$ inscription.

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

Output: For each test case, output an integer $$$k$$$ — the number of moves used to sort the columns. ($$$0 \leq k \leq n$$$)

Then, output $$$k$$$ lines, each containing two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$), representing the indices of the columns involved in the $$$i$$$-th move. During each move, it must hold that $$$|a_{u_i} - a_{v_i}| = 1$$$, and one inscription is transferred from the column with more inscriptions to the other.

It can be proven that a valid solution always exists under the given constraints.

Examples:
input:
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
output:
2
2 4
2 3
2
3 1
2 3
0

Note: Columns state in the first test case:

- Initial: $$$0, 2, 0, 1$$$
- After the first move: $$$0, 1, 0, 2$$$
- After the second move: $$$0, 0, 1, 2$$$

Columns state in the second test case:

- Initial: $$$1, 2, 0$$$
- After the first move: $$$0, 2, 1$$$
- After the second move: $$$0, 1, 2$$$

In the third test case, the column heights are already sorted in ascending order.

Buggy Code:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <unordered_map>
using namespace std;
#define int long long
#define ll long long
//#define endl '\n'
const int mod = 1e9+7;
const ll inf = 1e9 + 5;
const int N = 1e5 + 5;
int d[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
char ds[4]={'U','L','D','R'};
int gcd(int a,int b){
    while(a%b){
        int t=a%b;
        a=b;
        b=t;
    }
    return b;
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int qpow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
int m(int x,int y){
	int z=0;
	while(((x>>z)&1)!=1||((ll)1<<z)<y){
			z++;
	}
	return (ll)1<<z;
}
int ask(int a, int b){
  cout<<"? "<<a<<" "<<b<<endl;
  int x;cin>>x;
  return x;
}
void solve() {
    int n;cin>>n;
    vector<int> a(n);
    int x=0,y=0,z=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            x++;
        }else if(a[i]==1){
            y++;
        }else{
            z++;
        }
    }
    vector<pair<int,int>> ans;
    stack<int> s;
    for(int i=x+y;i<n;i++){
        if(a[i]==0)s.push(i);
    }
    for(int i=0;i<x+y;i++){
        if(a[i]==1){
            if(!s.empty()){
                int t=s.top();
                s.pop();
                ans.push_back({i,t});
                a[i]--;
                a[t]++;
            }
        }
    }
    for(int i=x+y;i<n;i++){
        if(a[i]==1)s.push(i);
    }
    for(int i=0;i<x+y;i++){
        if(a[i]==2){
            if(!s.empty()){
                int t=s.top();
                s.pop();
                ans.push_back({i,t});
                a[i]--;
                a[t]++;
            }
        }
    }
    for(int i=x;i<n;i++){
        if(a[i]==0)s.push(i);
    }
    for(int i=0;i<x;i++){
        if(a[i]==1){
            if(!s.empty()){
                int t=s.top();
                s.pop();
                ans.push_back({i,t});
                a[i]--;
                a[t]++;
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto it:ans){
        cout<<it.first+1<<" "<<it.second+1<<endl;
    }

    return;
}
signed main()
{
    iostream::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	// int t=1;
    int t;cin>>t;
   while(t--){
     solve();
   }
  return 0;
}
//n*a-b=n*(a-b)

**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 or scenarios that might cause the code to fail. Here are some considerations:

1. **Initial Configuration with All Columns Having the Same Number of Inscriptions**: This can test how the code handles uniform initial conditions.
2. **Initial Configuration with a Single Column Having a Different Number of Inscriptions**: This can test how the code handles minimal differences.
3. **Initial Configuration with Columns Already Sorted**: This can test how the code handles an already sorted input.
4. **Initial Configuration with a Large Number of Columns**: This can test the code's efficiency and correctness under more complex scenarios.

Given the constraints, let's focus on a small-scale test input that can expose potential issues. A good candidate is a test case where the columns are almost sorted but require specific moves to achieve the correct order.

### Challenging Test Input
```plaintext
3
4
1 2 0 1
5
2 0 1 2 1
6
0 1 1 2 2 1
```

### Explanation
1. **First Test Case (4 columns)**:
   - Initial: `1 2 0 1`
   - This configuration requires moving inscriptions to achieve a sorted order.
   - Expected moves:
     - Move 1 from column 1 to column 3: `0 2 1 1`
     - Move 1 from column 2 to column 3: `0 1 2 1`
     - Move 1 from column 4 to column 3: `0 1 1 2`

2. **Second Test Case (5 columns)**:
   - Initial: `2 0 1 2 1`
   - This configuration requires multiple moves to achieve a sorted order.
   - Expected moves:
     - Move 1 from column 1 to column 2: `1 1 1 2 1`
     - Move 1 from column 4 to column 3: `1 1 2 1 1`
     - Move 1 from column 4 to column 3: `1 1 1 2 1`
     - Move 1 from column 5 to column 3: `1 1 1 1 2`

3. **Third Test Case (6 columns)**:
   - Initial: `0 1 1 2 2 1`
   - This configuration requires multiple moves to achieve a sorted order.
   - Expected moves:
     - Move 1 from column 4 to column 6: `0 1 1 1 2 2`
     - Move 1 from column 5 to column 6: `0 1 1 1 1 3`
     - Move 1 from column 6 to column 3: `0 1 2 1 1 2`
     - Move 1 from column 6 to column 2: `0 2 2 1 1 1`
     - Move 1 from column 2 to column 1: `1 1 2 1 1 1`

This test input is designed to challenge the code by requiring it to handle multiple moves and different initial configurations, ensuring that the code's logic for moving inscriptions is robust.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Darius' Wisdom
time_limit_ms: 2000
memory_limit_mb: 256
Description: Darius the Great is constructing $$$n$$$ stone columns, each consisting of a base and between $$$0$$$, $$$1$$$, or $$$2$$$ inscription pieces stacked on top.

In each move, Darius can choose two columns $$$u$$$ and $$$v$$$ such that the difference in the number of inscriptions between these columns is exactly $$$1$$$, and transfer one inscription from the column with more inscriptions to the other one. It is guaranteed that at least one column contains exactly $$$1$$$ inscription.

Since beauty is the main pillar of historical buildings, Darius wants the columns to have ascending heights. To avoid excessive workers' efforts, he asks you to plan a sequence of at most $$$n$$$ moves to arrange the columns in non-decreasing order based on the number of inscriptions. Minimizing the number of moves is not required.

Input: The first line contains an integer $$$t$$$ — the number of test cases. ($$$1 \leq t \leq 3000$$$)

The first line of each test case contains an integer $$$n$$$ — the number of stone columns. ($$$1 \leq n \leq 2 \cdot 10^5$$$)

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i \in \{0,1,2\}$$$ represents the initial number of inscriptions in the $$$i$$$-th column. It is guaranteed that at least one column has exactly $$$1$$$ inscription.

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

Output: For each test case, output an integer $$$k$$$ — the number of moves used to sort the columns. ($$$0 \leq k \leq n$$$)

Then, output $$$k$$$ lines, each containing two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$), representing the indices of the columns involved in the $$$i$$$-th move. During each move, it must hold that $$$|a_{u_i} - a_{v_i}| = 1$$$, and one inscription is transferred from the column with more inscriptions to the other.

It can be proven that a valid solution always exists under the given constraints.

Examples:
input:
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
output:
2
2 4
2 3
2
3 1
2 3
0

Note: Columns state in the first test case:

- Initial: $$$0, 2, 0, 1$$$
- After the first move: $$$0, 1, 0, 2$$$
- After the second move: $$$0, 0, 1, 2$$$

Columns state in the second test case:

- Initial: $$$1, 2, 0$$$
- After the first move: $$$0, 2, 1$$$
- After the second move: $$$0, 1, 2$$$

In the third test case, the column heights are already sorted in ascending order.

Buggy Code:
import heapq
def solve():
    n = int(input())
    s = list(map(int, input().split()))
    moves = []
    f = {0:0, 1:0, 2:0}
    stack = [[] for i in range(n)]
    for i in range(n):
        stack[s[i]].append(i)
    heapq.heapify(stack[0])
    heapq.heapify(stack[1])
    heapq.heapify(stack[2])
    i = 0
    while stack[0] and i < n:
        if s[i] == 0:
            heapq.heappop(stack[0])
            i += 1
        elif s[i] == 1:
            j = heapq.heappop(stack[0])
            heapq.heappush(stack[1],j)
            heapq.heappop(stack[1])
            moves.append([i,j])
            s[i],s[j] = 0,1
            i += 1
        else:
            j = heapq.heappop(stack[1])
            heapq.heappush(stack[1],i)
            heapq.heappush(stack[2],j)
            moves.append([i,j])
            s[i],s[j] = 1,2
    while stack[1] and i < n:
        if s[i] == 1:
            heapq.heappop(stack[1])
            i += 1
        else:
            j = heapq.heappop(stack[1])
            heapq.heappush(stack[2],j)
            heapq.heappop(stack[2])
            moves.append([i,j])
            s[i],s[j] = 1,2
            i += 1
    return moves

# Main driver function
if __name__ == "__main__":
    t = int(input())  # Number of test cases
    for _ in range(t):
        moves = solve()
        print(len(moves))
        for m in moves:
            print(m[0]+1,end = " ")
            print(m[1]+1)

**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 focus on scenarios where the code might fail. The key points to consider are:

1. **Edge Cases**: Test with the smallest and largest possible values for `n`.
2. **Special Configurations**: Test with configurations where the initial order of inscriptions is such that the code might struggle to sort them correctly.
3. **Multiple Test Cases**: Test with multiple test cases to ensure the code handles different scenarios.

Given the constraints and the nature of the problem, a small-scale test input that can expose the bug is:

```plaintext
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
```

This input includes:
1. A test case with `n = 4` where the initial configuration is `0 2 0 1`.
2. A test case with `n = 3` where the initial configuration is `1 2 0`.
3. A test case with `n = 6` where the initial configuration is `0 1 1 2 2 2`.

These test cases are designed to:
- Test the handling of multiple columns with different initial inscriptions.
- Test the handling of a column with exactly 1 inscription.
- Test the sorting process and the movement of inscriptions between columns.

By using these test cases, we can observe if the code correctly sorts the columns and performs the moves as expected. If the code fails, it will likely be in the handling of the moves or in the logic that ensures the columns are sorted in non-decreasing order.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Darius' Wisdom
time_limit_ms: 2000
memory_limit_mb: 256
Description: Darius the Great is constructing $$$n$$$ stone columns, each consisting of a base and between $$$0$$$, $$$1$$$, or $$$2$$$ inscription pieces stacked on top.

In each move, Darius can choose two columns $$$u$$$ and $$$v$$$ such that the difference in the number of inscriptions between these columns is exactly $$$1$$$, and transfer one inscription from the column with more inscriptions to the other one. It is guaranteed that at least one column contains exactly $$$1$$$ inscription.

Since beauty is the main pillar of historical buildings, Darius wants the columns to have ascending heights. To avoid excessive workers' efforts, he asks you to plan a sequence of at most $$$n$$$ moves to arrange the columns in non-decreasing order based on the number of inscriptions. Minimizing the number of moves is not required.

Input: The first line contains an integer $$$t$$$ — the number of test cases. ($$$1 \leq t \leq 3000$$$)

The first line of each test case contains an integer $$$n$$$ — the number of stone columns. ($$$1 \leq n \leq 2 \cdot 10^5$$$)

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i \in \{0,1,2\}$$$ represents the initial number of inscriptions in the $$$i$$$-th column. It is guaranteed that at least one column has exactly $$$1$$$ inscription.

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

Output: For each test case, output an integer $$$k$$$ — the number of moves used to sort the columns. ($$$0 \leq k \leq n$$$)

Then, output $$$k$$$ lines, each containing two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$), representing the indices of the columns involved in the $$$i$$$-th move. During each move, it must hold that $$$|a_{u_i} - a_{v_i}| = 1$$$, and one inscription is transferred from the column with more inscriptions to the other.

It can be proven that a valid solution always exists under the given constraints.

Examples:
input:
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
output:
2
2 4
2 3
2
3 1
2 3
0

Note: Columns state in the first test case:

- Initial: $$$0, 2, 0, 1$$$
- After the first move: $$$0, 1, 0, 2$$$
- After the second move: $$$0, 0, 1, 2$$$

Columns state in the second test case:

- Initial: $$$1, 2, 0$$$
- After the first move: $$$0, 2, 1$$$
- After the second move: $$$0, 1, 2$$$

In the third test case, the column heights are already sorted in ascending order.

Buggy Code:
def main():
    import sys
    input = sys.stdin.read
    data = input().split()

    idx = 0
    t = int(data[idx])
    idx += 1
    for _ in range(t):
        n = int(data[idx])
        idx += 1
        a = list(map(int, data[idx:idx+n]))
        idx += n

        count_0 = a.count(0)
        count_1 = a.count(1)
        count_2 = a.count(2)

        moves = []
        sorted_a = [0] * count_0 + [1] * count_1 + [2] * count_2

        for i in range(n):
            if a[i] == sorted_a[i]:
                continue
            if a[i] > sorted_a[i]:
                # Need to transfer excess inscriptions to columns that need them
                for j in range(i+1, n):
                    if a[j] < sorted_a[j] and abs(a[i] - a[j]) == 1:
                        # Transfer from i to j
                        moves.append((i+1, j+1))
                        a[i] -= 1
                        a[j] += 1
                        if a[i] == sorted_a[i]:
                            break
            elif a[i] < sorted_a[i]:
                # Need to transfer inscriptions from columns that have excess
                for j in range(i):
                    if a[j] > sorted_a[j] and abs(a[i] - a[j]) == 1:
                        # Transfer from j to i
                        moves.append((j+1, i+1))
                        a[j] -= 1
                        a[i] += 1
                        if a[i] == sorted_a[i]:
                            break

        print(len(moves))
        for move in moves:
            print(move[0], move[1])

if __name__ == "__main__":
    main()

# jFCm6gQD0N1oJ4SU7kK

**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 consider edge cases where the code might fail. The code logic involves transferring inscriptions to achieve a sorted order. Common issues can arise from:

1. **Initial Configuration**: The initial configuration of the columns can lead to suboptimal or incorrect moves.
2. **Edge Cases**: Scenarios where the number of columns is minimal or the distribution of inscriptions is skewed.
3. **Repetitive Patterns**: Patterns that might cause the code to get stuck in an infinite loop or fail to find valid moves.

Given these considerations, let's create a small-scale test input that is likely to expose the bug:

```plaintext
3
4
0 2 2 1
3
2 1 0
5
0 2 0 2 1
```

### Explanation of the Test Cases

1. **Test Case 1:**
   - Initial: `0 2 2 1`
   - Expected Output: The columns should be sorted to `0 1 2 2`.
   - This case tests the ability to handle multiple columns with the same number of inscriptions and the need to transfer inscriptions from one column to another to achieve the sorted order.

2. **Test Case 2:**
   - Initial: `2 1 0`
   - Expected Output: The columns should be sorted to `0 1 2`.
   - This case tests the ability to handle a small number of columns and the need to transfer inscriptions in a specific order to achieve the sorted order.

3. **Test Case 3:**
   - Initial: `0 2 0 2 1`
   - Expected Output: The columns should be sorted to `0 0 1 2 2`.
   - This case tests the ability to handle multiple columns with the same number of inscriptions and the need to transfer inscriptions efficiently to achieve the sorted order.

These test cases are designed to be small enough to be manageable and to expose potential issues in the code's logic for handling inscriptions and achieving the sorted order.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Darius' Wisdom
time_limit_ms: 2000
memory_limit_mb: 256
Description: Darius the Great is constructing $$$n$$$ stone columns, each consisting of a base and between $$$0$$$, $$$1$$$, or $$$2$$$ inscription pieces stacked on top.

In each move, Darius can choose two columns $$$u$$$ and $$$v$$$ such that the difference in the number of inscriptions between these columns is exactly $$$1$$$, and transfer one inscription from the column with more inscriptions to the other one. It is guaranteed that at least one column contains exactly $$$1$$$ inscription.

Since beauty is the main pillar of historical buildings, Darius wants the columns to have ascending heights. To avoid excessive workers' efforts, he asks you to plan a sequence of at most $$$n$$$ moves to arrange the columns in non-decreasing order based on the number of inscriptions. Minimizing the number of moves is not required.

Input: The first line contains an integer $$$t$$$ — the number of test cases. ($$$1 \leq t \leq 3000$$$)

The first line of each test case contains an integer $$$n$$$ — the number of stone columns. ($$$1 \leq n \leq 2 \cdot 10^5$$$)

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i \in \{0,1,2\}$$$ represents the initial number of inscriptions in the $$$i$$$-th column. It is guaranteed that at least one column has exactly $$$1$$$ inscription.

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

Output: For each test case, output an integer $$$k$$$ — the number of moves used to sort the columns. ($$$0 \leq k \leq n$$$)

Then, output $$$k$$$ lines, each containing two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$), representing the indices of the columns involved in the $$$i$$$-th move. During each move, it must hold that $$$|a_{u_i} - a_{v_i}| = 1$$$, and one inscription is transferred from the column with more inscriptions to the other.

It can be proven that a valid solution always exists under the given constraints.

Examples:
input:
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
output:
2
2 4
2 3
2
3 1
2 3
0

Note: Columns state in the first test case:

- Initial: $$$0, 2, 0, 1$$$
- After the first move: $$$0, 1, 0, 2$$$
- After the second move: $$$0, 0, 1, 2$$$

Columns state in the second test case:

- Initial: $$$1, 2, 0$$$
- After the first move: $$$0, 2, 1$$$
- After the second move: $$$0, 1, 2$$$

In the third test case, the column heights are already sorted in ascending order.

Buggy Code:
from sys import stdin, stdout
from itertools import repeat
def solve():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split(), repeat(10, n))
    ans = []
    l, r = 0, n - 1
    while l < r:
        if a[l] != 1:
            l += 1
        elif a[r] != 0:
            r -= 1
        else:
            a[l] -= 1
            a[r] += 1
            ans.append((l + 1, r + 1))
            l += 1
            r -= 1
    l, r = 0, n - 1
    while l < r:
        if a[l] != 2:
            l += 1
        elif a[r] != 1:
            r -= 1
        else:
            a[l] -= 1
            a[r] += 1
            ans.append((l + 1, r + 1))
            l += 1
            r -= 1
    l, r = 0, n - 1
    while l < r:
        if a[l] != 1:
            l += 1
        elif a[r] != 0:
            r -= 1
        else:
            a[l] -= 1
            a[r] += 1
            ans.append((l + 1, r + 1))
            l += 1
            r -= 1
    l, r = 0, n - 1
    while l < r:
        if a[l] != 2:
            l += 1
        elif a[r] != 1:
            r -= 1
        else:
            a[l] -= 1
            a[r] += 1
            ans.append((l + 1, r + 1))
            l += 1
            r -= 1
    stdout.write(str(len(ans)) + '\n')
    stdout.write('\n'.join('%d %d' % x for x in ans))
    stdout.write('\n')

T = int(stdin.readline())
for t in xrange(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
3
4
0 2 1 0
3
0 2 1
6
0 1 2 2 1 0
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Darius' Wisdom
time_limit_ms: 2000
memory_limit_mb: 256
Description: Darius the Great is constructing $$$n$$$ stone columns, each consisting of a base and between $$$0$$$, $$$1$$$, or $$$2$$$ inscription pieces stacked on top.

In each move, Darius can choose two columns $$$u$$$ and $$$v$$$ such that the difference in the number of inscriptions between these columns is exactly $$$1$$$, and transfer one inscription from the column with more inscriptions to the other one. It is guaranteed that at least one column contains exactly $$$1$$$ inscription.

Since beauty is the main pillar of historical buildings, Darius wants the columns to have ascending heights. To avoid excessive workers' efforts, he asks you to plan a sequence of at most $$$n$$$ moves to arrange the columns in non-decreasing order based on the number of inscriptions. Minimizing the number of moves is not required.

Input: The first line contains an integer $$$t$$$ — the number of test cases. ($$$1 \leq t \leq 3000$$$)

The first line of each test case contains an integer $$$n$$$ — the number of stone columns. ($$$1 \leq n \leq 2 \cdot 10^5$$$)

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i \in \{0,1,2\}$$$ represents the initial number of inscriptions in the $$$i$$$-th column. It is guaranteed that at least one column has exactly $$$1$$$ inscription.

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

Output: For each test case, output an integer $$$k$$$ — the number of moves used to sort the columns. ($$$0 \leq k \leq n$$$)

Then, output $$$k$$$ lines, each containing two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$), representing the indices of the columns involved in the $$$i$$$-th move. During each move, it must hold that $$$|a_{u_i} - a_{v_i}| = 1$$$, and one inscription is transferred from the column with more inscriptions to the other.

It can be proven that a valid solution always exists under the given constraints.

Examples:
input:
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
output:
2
2 4
2 3
2
3 1
2 3
0

Note: Columns state in the first test case:

- Initial: $$$0, 2, 0, 1$$$
- After the first move: $$$0, 1, 0, 2$$$
- After the second move: $$$0, 0, 1, 2$$$

Columns state in the second test case:

- Initial: $$$1, 2, 0$$$
- After the first move: $$$0, 2, 1$$$
- After the second move: $$$0, 1, 2$$$

In the third test case, the column heights are already sorted in ascending order.

Buggy Code:
import static java.lang.Math.max;
    import static java.lang.Math.min;
    import static java.lang.Math.abs;

    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.PrintWriter;
    import java.lang.reflect.Array;
    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Objects;
    import java.util.Map;
    import java.util.Random;
    import java.util.TreeSet;

    public class D_Darius_Wisdom {
        static final int MOD = (int)1e9 + 7;
        static final FastScanner in = new FastScanner();
        static final PrintWriter out = new PrintWriter(System.out);

        public static void main(String[] args) {

            int T = in.nextInt();

            while(T-- > 0) {

                int n = in.nextInt();

                int[] a = readArray(n);

                TreeSet<Integer> posOne = new TreeSet<>();

                for(int i = 1; i <= n; ++i) {
                    if(a[i] == 1) posOne.add(i);
                }

                int l = 1, r = n;

                ArrayList<int[]> ans = new ArrayList<>();

                while(l < r) {
                    if(a[l] == 0) {
                        ++l;
                        continue;
                    }

                    while(l < r && a[r] != 0) --r;

                    if(r <= l) break;

                    if(a[l] == 1) {
                        ans.add(new int[] {l, r});
                        swap(a, l, r);
                        posOne.remove(l);
                        posOne.add(r);
                        --r;
                    }
                    else {
                        int lastIdx = posOne.last();
                        ans.add(new int[] {l, lastIdx});
                        ans.add(new int[] {l, r});
                        swap(a, l, lastIdx);
                        swap(a, l, r);
                        posOne.remove(lastIdx);
                        posOne.add(r);
                        --r;
                    }
                    ++l;
                }

                r = n;

                while(l < n) {
                    if(a[l] == 1) {
                        ++l;
                        continue;
                    }

                    while(l < r && a[r] == 2) {
                        --r;
                    }

                    if(r <= l) break;

                    int lastIdx = posOne.last();
                    ans.add(new int[] {l, lastIdx});
                    swap(a, l, lastIdx);
                    posOne.remove(lastIdx);
                    ++l;
                }

                out.println(ans.size());

                for(int[] p : ans) {
                    out.println(p[0] + " " + p[1]);
                }

            }

            out.close();

        }

        // Remember to initialize the whole adj list
        // with empty arraylist.
        // static void dfs(int node) {
            // visited[node] = true;
            // Just after entering the node.

        //  for (int child : g[node]) {
                // Take action on each child
            //   if (!visited[child])
                //    dfs(child);
            //}

            // Take action after exiting all the
            // childs

        // }

        static long binPow(long a, long n, long mod) {
            long res = 1L;

            while(n > 0L) {
                if((n & 1L) == 1L) res = ((a % mod) * (res % mod)) % mod;

                a = ((a % mod) * (a % mod)) % mod;
                n >>= 1;
            }

            return res;
        }

        // Strictly lesser than target if less than equal to target < := <=
        static int lowerBound(long[] a, int l, int r, long target) {
            while (l <= r) {
                int mid = (r - l) / 2 + l;

                if (a[mid] < target) {
                    l = mid + 1;
                } else {
                    r = mid - 1;
                }
            }
            return r;
        }

        // Strictly greater than target if greater than equal to target <= := <
        static int upperBound(long[] a, int l, int r, long target) {
            while (l <= r) {
                int mid = (r - l) / 2 + l;

                if (a[mid] <= target) {
                    l = mid + 1;
                } else {
                    r = mid - 1;
                }
            }
            return l;
        }

        // Strictly greater than target if greater than equal to target <= := <
        static int upperBound(int[] a, int l, int r, int target) {
            while (l <= r) {
                int mid = (r - l) / 2 + l;

                if (a[mid] <= target) {
                    l = mid + 1;
                } else {
                    r = mid - 1;
                }
            }
            return l;
        }

        // Strictly lesser than target if less than equal to target < := <=
        static int lowerBound(int[] a, int l, int r, int target) {
            while (l <= r) {
                int mid = (r - l) / 2 + l;

                if (a[mid] < target) {
                    l = mid + 1;
                } else {
                    r = mid - 1;
                }
            }
            return r;
        }

        static void push(Map<Long, Long> mp, long k, long v) {
            if (mp.containsKey(k)) {
                mp.put(k, mp.get(k) + v);
            } else {
                mp.put(k, v);
            }
        }

        static void pull(Map<Long, Long> mp, long k, long v) {
            long x = mp.get(k);

            if (v >= x)
                mp.remove(k);
            else
                mp.put(k, x - v);
        }

        static boolean isPrime(long n) {
            if (n < 2)
                return false;
            if (n == 2 || n == 3)
                return true;
            if (n % 2 == 0 || n % 3 == 0)
                return false;

            for (long i = 6; i * i <= n; i += 6) {
                if ((n % (i - 1) == 0) || (n % (i + 1) == 0)) {
                    return false;
                }
            }

            return true;
        }

        static long gcd(long a, long b) {
            return b == 0L ? a : gcd(b, a % b);
        }

        static void reverse(int[] a, int l, int r) {
            while (l < r)
                swap(a, l++, r--);
        }

        static void reverse(long[] a, int l, int r) {
            while (l < r)
                swap(a, l++, r--);
        }

        static void swap(long[] a, int l, int r) {
            long temp = a[l];
            a[l] = a[r];
            a[r] = temp;
        }

        static void swap(int[] a, int l, int r) {
            int temp = a[l];
            a[l] = a[r];
            a[r] = temp;
        }

        static void ruffleSort(long[] a, int l, int r) {
            shuffleArray(a, l, r);
            Arrays.sort(a, l, r + 1);
        }

        static void ruffleSort(int[] a, int l, int r) {
            shuffleArray(a, l, r);
            Arrays.sort(a, l, r + 1);
        }

        static void shuffleArray(int[] arr, int l, int r) {
            Random rnd = new Random();
            for (int i = l; i <= r; ++i) {
                int tmp = arr[i];
                int randomPos = i + rnd.nextInt(r - i + 1);
                arr[i] = arr[randomPos];
                arr[randomPos] = tmp;
            }
        }

        static void shuffleArray(long[] arr, int l, int r) {
            Random rnd = new Random();
            for (int i = l; i <= r; ++i) {
                long tmp = arr[i];
                int randomPos = i + rnd.nextInt(r - i + 1);
                arr[i] = arr[randomPos];
                arr[randomPos] = tmp;
            }
        }

        static long[] readArrayL(int n) {
            long[] a = new long[n + 1];

            for (int i = 1; i <= n; ++i) {
                a[i] = in.nextLong();
            }

            return a;
        }

        static ArrayList<Integer> readList(int n) {
            ArrayList<Integer> list = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                list.add(in.nextInt());
            }

            return list;
        }

        static int[] readArray(int n) {
            int[] arr = new int[n + 1];

            for (int i = 1; i <= n; i++) {
                arr[i] = in.nextInt();
            }

            return arr;
        }

        static class FastScanner {
            // I don't understand how this works lmao
            private int BS = 1 << 16;
            private char NC = (char) 0;
            private byte[] buf = new byte[BS];
            private int bId = 0, size = 0;
            private char c = NC;
            private double cnt = 1;
            private InputStream in;

            public FastScanner() {
                in = new BufferedInputStream(System.in, BS);
            }

            public FastScanner(String s) {
                try {
                    in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
                } catch (Exception e) {
                    in = new BufferedInputStream(System.in, BS);
                }
            }

            private char nextChar() {
                while (bId == size) {
                    try {
                        size = in.read(buf);
                    } catch (Exception e) {
                        return NC;
                    }
                    if (size == -1)
                        return NC;
                    bId = 0;
                }
                return (char) buf[bId++];
            }

            public int nextInt() {
                return (int) nextLong();
            }

            public long nextLong() {
                cnt = 1;
                boolean neg = false;
                if (c == NC)
                    c = nextChar();
                for (; (c < '0' || c > '9'); c = nextChar()) {
                    if (c == '-')
                        neg = true;
                }
                long res = 0;
                for (; c >= '0' && c <= '9'; c = nextChar()) {
                    res = (res << 3) + (res << 1) + c - '0';
                    cnt *= 10;
                }
                return neg ? -res : res;
            }

            public double nextDouble() {
                double cur = nextLong();
                return c != '.' ? cur : cur + nextLong() / cnt;
            }

            public String next() {
                StringBuilder res = new StringBuilder();
                while (c <= 32)
                    c = nextChar();
                while (c > 32) {
                    res.append(c);
                    c = nextChar();
                }
                return res.toString();
            }

            public String nextLine() {
                StringBuilder res = new StringBuilder();
                while (c <= 32)
                    c = nextChar();
                while (c != '\n') {
                    res.append(c);
                    c = nextChar();
                }
                return res.toString();
            }

            public boolean hasNext() {
                if (c > 32)
                    return true;
                while (true) {
                    c = nextChar();
                    if (c == NC)
                        return false;
                    else if (c > 32)
                        return 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:
To generate a challenging test input that exposes the bug in the provided code, we need to consider edge cases that might cause the code to fail. Here are the steps to think through this:

1. **Understand the Code Logic**:
   - The code uses a `TreeSet` to keep track of the positions of columns with 1 inscription.
   - It iterates through the columns, attempting to move inscriptions to sort the columns in non-decreasing order.

2. **Identify Potential Bugs**:
   - The code might fail if it incorrectly handles the case where there are multiple columns with 1 inscription.
   - The code might also fail if it incorrectly handles the boundaries of the array, especially when `l` and `r` are close to each other.

3. **Construct a Small-Scale Test Input**:
   - We need a test case that has a small number of columns but is complex enough to expose the bug.
   - A good test case might be one where the initial configuration of columns is such that the code needs to make multiple moves to sort the columns correctly.

4. **Test Case**:
   - Consider a test case with 5 columns: `1 2 0 2 1`.
   - This test case has multiple columns with 1 inscription and requires multiple moves to sort the columns correctly.

Here is the test input:

```plaintext
1
5
1 2 0 2 1
```

This test input is designed to challenge the code by requiring multiple moves and handling multiple columns with 1 inscription. Let's break down why this test case is challenging:

- **Initial Configuration**: `1 2 0 2 1`
- **Expected Moves**:
  - Move 1: `2 1` (Move an inscription from column 2 to column 1)
  - Move 2: `4 3` (Move an inscription from column 4 to column 3)
  - Move 3: `2 4` (Move an inscription from column 2 to column 4)

The final configuration should be `1 1 1 1 2`.

This test case will help expose any issues in the code's logic for handling multiple columns with 1 inscription and ensuring the correct number of moves to sort the columns.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Darius' Wisdom
time_limit_ms: 2000
memory_limit_mb: 256
Description: Darius the Great is constructing $$$n$$$ stone columns, each consisting of a base and between $$$0$$$, $$$1$$$, or $$$2$$$ inscription pieces stacked on top.

In each move, Darius can choose two columns $$$u$$$ and $$$v$$$ such that the difference in the number of inscriptions between these columns is exactly $$$1$$$, and transfer one inscription from the column with more inscriptions to the other one. It is guaranteed that at least one column contains exactly $$$1$$$ inscription.

Since beauty is the main pillar of historical buildings, Darius wants the columns to have ascending heights. To avoid excessive workers' efforts, he asks you to plan a sequence of at most $$$n$$$ moves to arrange the columns in non-decreasing order based on the number of inscriptions. Minimizing the number of moves is not required.

Input: The first line contains an integer $$$t$$$ — the number of test cases. ($$$1 \leq t \leq 3000$$$)

The first line of each test case contains an integer $$$n$$$ — the number of stone columns. ($$$1 \leq n \leq 2 \cdot 10^5$$$)

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i \in \{0,1,2\}$$$ represents the initial number of inscriptions in the $$$i$$$-th column. It is guaranteed that at least one column has exactly $$$1$$$ inscription.

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

Output: For each test case, output an integer $$$k$$$ — the number of moves used to sort the columns. ($$$0 \leq k \leq n$$$)

Then, output $$$k$$$ lines, each containing two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$), representing the indices of the columns involved in the $$$i$$$-th move. During each move, it must hold that $$$|a_{u_i} - a_{v_i}| = 1$$$, and one inscription is transferred from the column with more inscriptions to the other.

It can be proven that a valid solution always exists under the given constraints.

Examples:
input:
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
output:
2
2 4
2 3
2
3 1
2 3
0

Note: Columns state in the first test case:

- Initial: $$$0, 2, 0, 1$$$
- After the first move: $$$0, 1, 0, 2$$$
- After the second move: $$$0, 0, 1, 2$$$

Columns state in the second test case:

- Initial: $$$1, 2, 0$$$
- After the first move: $$$0, 2, 1$$$
- After the second move: $$$0, 1, 2$$$

In the third test case, the column heights are already sorted in ascending order.

Buggy Code:
import java.util.ArrayList;
// import java.util.Arrays;
import java.util.Scanner;

public class prog2034D {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int testcases = sc.nextInt();
        while (testcases-->0) {
            int n= sc.nextInt();
            sc.nextLine();
            int[] arr = new int[n];
            for (int i = 0; i < arr.length; i++) {
                arr[i]=sc.nextInt();
            }
            ArrayList<int[]> a = new ArrayList<>();
            for (int k = 0; k < n; k++) {
                for (int i = 0; i < n; i++) {
                    for (int j = i+1; j < n; j++) {
                        if (arr[i]==1+arr[j]) {
                            a.add(new int[] {i, j});
                            int temp = arr[i];
                            arr[i]=arr[j];
                            arr[j]=temp;
                        }
                    }
                }
            }

            System.out.println(a.size());

            for (int[] elem : a) {
                System.out.println((elem[0]+1)+" "+ (elem[1]+1));
            }
            // System.out.println(Arrays.toString(arr));
            sc.nextLine();
        }
        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:
```plaintext
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Darius' Wisdom
time_limit_ms: 2000
memory_limit_mb: 256
Description: Darius the Great is constructing $$$n$$$ stone columns, each consisting of a base and between $$$0$$$, $$$1$$$, or $$$2$$$ inscription pieces stacked on top.

In each move, Darius can choose two columns $$$u$$$ and $$$v$$$ such that the difference in the number of inscriptions between these columns is exactly $$$1$$$, and transfer one inscription from the column with more inscriptions to the other one. It is guaranteed that at least one column contains exactly $$$1$$$ inscription.

Since beauty is the main pillar of historical buildings, Darius wants the columns to have ascending heights. To avoid excessive workers' efforts, he asks you to plan a sequence of at most $$$n$$$ moves to arrange the columns in non-decreasing order based on the number of inscriptions. Minimizing the number of moves is not required.

Input: The first line contains an integer $$$t$$$ — the number of test cases. ($$$1 \leq t \leq 3000$$$)

The first line of each test case contains an integer $$$n$$$ — the number of stone columns. ($$$1 \leq n \leq 2 \cdot 10^5$$$)

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, where $$$a_i \in \{0,1,2\}$$$ represents the initial number of inscriptions in the $$$i$$$-th column. It is guaranteed that at least one column has exactly $$$1$$$ inscription.

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

Output: For each test case, output an integer $$$k$$$ — the number of moves used to sort the columns. ($$$0 \leq k \leq n$$$)

Then, output $$$k$$$ lines, each containing two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i, v_i \leq n$$$), representing the indices of the columns involved in the $$$i$$$-th move. During each move, it must hold that $$$|a_{u_i} - a_{v_i}| = 1$$$, and one inscription is transferred from the column with more inscriptions to the other.

It can be proven that a valid solution always exists under the given constraints.

Examples:
input:
3
4
0 2 0 1
3
1 2 0
6
0 1 1 2 2 2
output:
2
2 4
2 3
2
3 1
2 3
0

Note: Columns state in the first test case:

- Initial: $$$0, 2, 0, 1$$$
- After the first move: $$$0, 1, 0, 2$$$
- After the second move: $$$0, 0, 1, 2$$$

Columns state in the second test case:

- Initial: $$$1, 2, 0$$$
- After the first move: $$$0, 2, 1$$$
- After the second move: $$$0, 1, 2$$$

In the third test case, the column heights are already sorted in ascending order.

Buggy Code:
#include<bits/stdc++.h>
//#ifdef LOCAL
//#pragma GCC optimize("trapv")
//#endif
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
ll getTime(){return chrono::steady_clock::now().time_since_epoch().count();}
mt19937_64 gen(getTime());
ll rndnext(ll l,ll r){
    uniform_int_distribution<ll> rng(l,r);
    return rng(gen);
}
const ll NMAX=5e5+5,LGMAX=20,STMAX=(1<<20)+5,MOD=998244353;
const ld eps=1e-12;
set<ll> pos[3];
vector<pll> ans;
ll v[NMAX];
void Swap(ll i, ll j){
    ans.push_back({i,j});
    pos[v[i]].erase(i);
    pos[v[j]].erase(j);
    swap(v[i],v[j]);
    pos[v[i]].insert(i);
    pos[v[j]].insert(j);
}
void swap02(ll i, ll k){
    ll j=*pos[1].begin();
    Swap(i,j);
    Swap(i,k);
    Swap(j,k);
}
void tc(){
    ll n;
    cin>>n;
    ans.clear();
    for(ll i=0;i<3;i++) pos[i].clear();
    ll cnt[3]{};
    for(ll i=1;i<=n;i++){
        cin>>v[i];
        ++cnt[v[i]];
        pos[v[i]].insert(i);
    }
    for(ll i=1;i<=n;i++){
        if(i<=cnt[0] && v[i]!=0){
            if(v[i]==1) Swap(i,*pos[0].rbegin());
            else if(v[i]==2) swap02(i,*pos[0].rbegin());
        }
        else if(i<=cnt[0]+cnt[1]){
            if(v[i]==2) Swap(i,*pos[1].rbegin());
        }
    }
    cout<<ans.size()<<'\n';
    for(auto it : ans) cout<<it.first<<' '<<it.second<<'\n';
}
int main()
{
    #ifdef LOCAL
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll t; cin>>t; while(t--)
        tc();
    return 0;
}

/**
Dormeau adanc sicriele de plumb
Si flori de plumb si funerar vestmant -
Stau singur in cavou... si era vant...
Si scartaiau coroanele de plumb.

Dormea intors amorul meu de plumb
Pe flori de plumb, si-am inceput sa-l strig -
Stam singur langa mort... si era frig...
Si-i atarnau aripile de plumb.
- folclor
*/

**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 given code, we need to consider edge cases and scenarios that might cause the code to fail. The code is designed to sort the columns in non-decreasing order based on the number of inscriptions, and it uses a set to keep track of the positions of columns with 0, 1, and 2 inscriptions.

Here are some key points to consider:
1. **Initial Configuration with Many Columns of the Same Type**: The code might fail if there are many columns with the same number of inscriptions, especially if the columns are not initially in the correct order.
2. **Edge Cases with Small Number of Columns**: Small test cases can help identify issues in the logic.
3. **Columns with Exactly One Inscription**: The code guarantees that at least one column has exactly one inscription, so we need to ensure this condition is met.
4. **Columns with Different Initial Heights**: The code should handle cases where the initial heights are not in the correct order.

Given these considerations, let's create a small-scale test input that might expose the bug:

```plaintext
3
4
0 1 2 2
3
2 1 0
5
1 2 0 2 0
```

### Explanation:
1. **Test Case 1: 4 Columns (0 1 2 2)**
   - Initial: 0, 1, 2, 2
   - The code should be able to sort this by moving the inscriptions appropriately.

2. **Test Case 2: 3 Columns (2 1 0)**
   - Initial: 2, 1, 0
   - This is a reverse order, and the code should be able to sort it to 0, 1, 2.

3. **Test Case 3: 5 Columns (1 2 0 2 0)**
   - Initial: 1, 2, 0, 2, 0
   - This has multiple columns with 2 inscriptions and multiple columns with 0 inscriptions, which should challenge the code's logic.

This test input is small and complete, and it covers a variety of scenarios that might expose the bug in the given code.