**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/extc++.h>

using namespace std;
using namespace __gnu_pbds;

// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

const long long mod = 1e9 + 7;
// const long long mod = 998244353;
const int precision = 24;
using db = long double;

template<class T> using vt = vector<T>;
using str = string;
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
using vi = vt<int>;
using vl = vt<ll>;
using vb = vt<bool>;
using vvi = vt<vt<int>>;
using vvl = vt<vt<ll>>;
using vvb = vt<vt<bool>>;
using vpi = vt<pi>;
using vpl = vt<pl>;

const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();

struct chash { // large odd number for C
    const uint64_t C = ll(4e18 * acos(0)) | 71;
    ll operator()(ll x) const { return __builtin_bswap64((x ^ RANDOM) * C); }
};

#define gptable gp_hash_table
template<class K, class V, class hash> gptable<K, V, hash> make_gptable() {
    return gptable<K, V, hash>({}, {}, {}, {}, {1 << 16});
}

#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define bg(x) begin(x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define size(x) ((int) (x).size())
#define sq(x) ((x) * (x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#ifndef LOCAL
#define endl '\n'
#endif

#define lb lower_bound
#define ub upper_bound
template<class T> int lwb(vt<T>& a, const T& b) { return int(lb(all(a), b) - bg(a)); }
template<class T> int upb(vt<T>& a, const T& b) { return int(ub(all(a), b) - bg(a)); }
template<class T> void rem_dup(vt<T>& v) { sort(all(v)); v.erase(unique(all(v)), v.end()); }
#define contains(a, x) find(all(x), a) == end(x)
#define cmp(exp) [&] (const auto& x, const auto& y) { return exp; }

#define __NARG__(...)  __NARG_I_(__VA_ARGS__,__RSEQ_N())
#define __NARG_I_(...) __ARG_N(__VA_ARGS__)
#define __ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
#define __RSEQ_N() 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0

#define _VFUNC_(name, n) name##n
#define _VFUNC(name, n) _VFUNC_(name, n)
#define VFUNC(func, ...) _VFUNC(func, __NARG__(__VA_ARGS__)) (__VA_ARGS__)

#define FOR2(i, b) for (int i = 0; i < (b); i++)
#define FOR3(i, a, b) for (int i = (a); i < (b); i++)
#define ROF2(i, b) for (int i = (b) - 1; i >= 0; i--)
#define ROF3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define rep(x) FOR (_, x)

#define each2(a, x) for (auto& a : x)
#define each3(a, b, x) for (auto& [a, b] : x)
#define each4(a, b, c, x) for (auto& [a, b, c] : x)

#define enum3(i, a, x) if (int i = 0; 1) for (auto it = begin(x); it != end(x); it++, i++) if (auto& a = *it; 1)
#define enum4(i, a, b, x) if (int i = 0; 1) for (auto it = begin(x); it != end(x); it++, i++) if (auto& [a, b] = *it; 1)
#define enum5(i, a, b, c, x) if (int i = 0; 1) for (auto it = begin(x); it != end(x); it++, i++) if (auto& [a, b, c] = *it; 1)

#define FOR(...) VFUNC(FOR, __VA_ARGS__)
#define ROF(...) VFUNC(ROF, __VA_ARGS__)
#define each(...) VFUNC(each, __VA_ARGS__)
#define enum(...) VFUNC(enum, __VA_ARGS__)

__gnu_cxx::sfmt19937 mt((uint32_t) chrono::steady_clock::now().time_since_epoch().count());
ll mpow(ll x, ll y = mod - 2) {
    ll res = 1;
    for (; y; x = (x * x) % mod, y >>= 1) if (y & 1) res = (res * x) % mod;
    return res;
}
ll gen(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(mt); }

int rs, cs;
const int dr[5] {0, -1, 0, 1, 0}, dc[5] {1, 0, -1, 0, 0};
bool valid(int r, int c) { return r >= 0 && c >= 0 && r < rs && c < cs; }
vpi get_adj(int r, int c) {
    vpi ret(4);
    FOR (i, 4) ret[i] = {r + dr[i], c + dc[i]};
    return ret;
}
vpi get_valid_adj(int r, int c) {
    vpi ret;
    FOR (i, 4) {
        int nr = r + dr[i];
        int nc = c + dc[i];
        if (valid(nr, nc)) ret.eb(nr, nc);
    }
    return ret;
}

constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int pctl(ll x) { return __builtin_popcountll(x); }
// 2 ^ bits(n) is the largest power of 2 <= n
constexpr int bits(int x) { return x ? 31 - __builtin_clz(x) : 0; }
constexpr int bits(ll x) { return x ? 63 - __builtin_clzll(x) : 0; }
constexpr int p2(int x) { return 1 << x; }
constexpr ll p2l(int x) { return 1ll << x; }
constexpr int msk2(int x) { return p2(x) - 1; }
constexpr ll msk2l(int x) { return p2l(x) - 1; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); }
ll fdiv(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); }

namespace IO {
#ifndef LOCAL
    const int BSZ = 1 << 15;
    char ibuf[BSZ]; int ipos, ilen;
    char _next_char() {
        if (ipos == ilen) {
            ipos = 0;
            ilen = fread(ibuf, 1, BSZ, stdin);
            if (!ilen) return EOF;
        }
        return ibuf[ipos++];
    }
    char _nc() {
        char ch;
        while (isspace(ch = _next_char()));
        return ch;
    }
    void _rc(char& ch) {
        while (isspace(ch = _next_char()));
    }
    string _ns() {
        string x;
        char ch; while (isspace(ch = _next_char()));
        do { x += ch; } while (!isspace(ch = _next_char()) && ch != EOF);
        return x;
    }
    void _rs(string& x) {
        char ch; while (isspace(ch = _next_char()));
        do { x += ch; } while (!isspace(ch = _next_char()) && ch != EOF);
    }
    int _ni() {
        int x, sgn = 1;
        char ch;
        while (!isdigit(ch = _next_char())) if (ch == '-') sgn *= -1;
        x = ch - '0';
        while (isdigit(ch = _next_char())) x = x * 10 + (ch - '0');
        return x * sgn;
    }
    ll _nl() {
        ll x, sgn = 1;
        char ch;
        while (!isdigit(ch = _next_char())) if (ch == '-') sgn *= -1;
        x = ch - '0';
        while (isdigit(ch = _next_char())) x = x * 10 + (ch - '0');
        return x * sgn;
    }
    template<class T> void _ri(T& x) {
        char ch;
        int sgn = 1;
        while (!isdigit(ch = _next_char())) if (ch == '-') sgn *= -1;
        x = ch - '0';
        while (isdigit(ch = _next_char())) x = x * 10 + (ch - '0');
        x *= sgn;
    }
    template<class T, class... Ts> void _ri(T& t, Ts&... ts) { _ri(t); _ri(ts...); }
    char obuf[BSZ], numBuf[100]; int opos;
    void flushOut() {
        fwrite(obuf, 1, opos, stdout); opos = 0;
    }
    void _wc(char c) {
        if (opos == BSZ) flushOut();
        obuf[opos++] = c;
    }
    void _ws(string s) { for (char& c : s) _wc(c); }
    template<class T> void _wi(T x) {
        if (x < 0) _wc('-'), x *= -1;
        int len = 0;
        for (; x >= 10; x /= 10) numBuf[len++] = '0' + (x % 10);
        _wc('0' + x);
        for (int i = len - 1; i >= 0; i--) _wc(numBuf[i]);
    }
    template <typename T>
    typename std::enable_if<std::is_floating_point<T>::value>::type _rf(T &x) {
        str in; _rs(in); x = stold(in);
    }
    template <typename T>
    typename std::enable_if<std::is_floating_point<T>::value>::type _wf(T& x) {
        ostringstream sout;
        sout << std::fixed << std::setprecision(precision) << x;
        str out = sout.str();
        each(c, out) _wc(c);
    }
    long double _nf() { long double x; _rf(x); return x; }
    void initO() { assert(atexit(flushOut) == 0); }
#else
    char _nc() { char ch; cin >> ch; return ch; }
    void _rc(char& ch) { cin >> ch; }
    string _ns() { string x; cin >> x; return x; }
    void _rs(string& x) { cin >> x; }
    int _ni() { int x; cin >> x; return x; }
    ll _nl() { ll x; cin >> x; return x; }
    template<class T> void _ri(T& x) { cin >> x; }
    template<class T, class... Ts> void _ri(T& t, Ts&... ts) { ri(t); ri(ts...); }
    void _wc(char c) {
        if (c == '\n') cout << endl;
        else cout << c;
    }
    void _ws(string s) { cout << s; }
    template<class T> void _wi(T x) { cout << x; }
    template <typename T>
    typename std::enable_if<std::is_floating_point<T>::value>::type _rf(T &x) { cin >> x; }
    template <typename T>
    typename std::enable_if<std::is_floating_point<T>::value>::type _wf(T& x) { cout << std::fixed << std::setprecision(precision) << x; }
    long double _nf() { long double x; _rf(x); return x; }
    void initO() { cin.tie(0)->sync_with_stdio(0); }
#endif
}

void setfileaio(string name) {
#ifndef LOCAL
    if (name == "") return;
    freopen((name + "in.txt").c_str(), "r", stdin);
    freopen((name + "out.txt").c_str(), "w", stdout);
#endif
}

void setfile(string pfx) {
#ifndef LOCAL
    if (pfx == "") return;
    freopen((pfx + ".in").c_str(), "r", stdin);
    freopen((pfx + ".out").c_str(), "w", stdout);
#endif
}

template<typename... Args> // tuples
ostream& operator<<(ostream& os, tuple<Args...> t) {
    apply([&](Args... args) { string dlm = "{"; ((os << dlm << args, dlm = ", "), ...); }, t);
    return os << "}";
}

template<typename T, typename V> // pairs
ostream& operator<<(ostream& os, pair<T, V> p) { return os << "{" << p.f << ", " << p.s << "}"; }

template<typename T, typename V>
istream& operator>>(istream& os, pair<T, V> p) { return os >> p.f >> p.s; }

template<class T, class = decltype(begin(declval<T>()))> // iterables
typename enable_if<!is_same<T, string>::value, ostream&>::type operator<<(ostream& os, const T& v) {
    os << "{";
    string dlm = "";
    for (auto i : v) os << dlm << i, dlm = ", ";
    return os << "}";
}

template<class T, class = decltype(begin(declval<T>()))>
typename enable_if<!is_same<T, string>::value, istream&>::type operator>>(istream& os, T& v) {
    for (auto& i : v) os >> i;
    return os;
}

void read(char& x) { x = IO::_nc(); }
template<typename T>
typename enable_if<is_integral<T>::value>::type read(T& x) { IO::_ri(x); }
template <typename T>
typename std::enable_if<std::is_floating_point<T>::value>::type read(T &x) { IO::_rf(x); }
void read(bool& x) { char c; read(c); x = (c == '1'); }
void read(string& x) { IO::_rs(x); }
template<class T, class U> void read(pair<T, U>& x) { read(x.f); read(x.s); }
template<class T, class = decltype(begin(declval<T>()))>
typename enable_if<!is_same<T, string>::value>::type read(T& v) { for (auto& i : v) read(i); }
template<class T, class... Ts> void read(T& t, Ts&... ts) { read(t); read(ts...); }

void _print(const char& c) { IO::_wc(c); }
template<typename T>
typename enable_if<is_integral<T>::value>::type _print(T x) { IO::_wi(x); }
template <typename T>
typename std::enable_if<std::is_floating_point<T>::value>::type _print(T& x) { IO::_wf(x); }
void _print(const bool& x) { IO::_wi(x); }
void _print(const string& x) { IO::_ws(x); }
void _print(const char* x) { IO::_ws(x); }
template<class T, class U>
void _print(const pair<T, U>& x) { _print(x.first); _print(' '); _print(x.second); }
template<class T, class = decltype(begin(declval<T>()))>
typename enable_if<!is_same<T, string>::value>::type _print(const T& v) { each(i, v) _print(i), _print(' '); }
template<class T> void print(const T& t) { _print(t); _print(' '); }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { _print(t); _print(' '); print(ts...); }
template <typename T>
void print(initializer_list<T> args) { each(e, args) _print(e); }
void println() { _print('\n'); }
template<class T> void println(const T& t) { _print(t); _print('\n'); }
template<class T, class... Ts> void println(const T& t, const Ts&... ts) { _print(t); _print(' '); println(ts...); }
template<class T>
void println(initializer_list<T> args) { each(e, args) _print(e); _print('\n'); }

int nxti() { return IO::_ni(); }
ll nxtl() { return IO::_nl(); }
char nxtc() { return IO::_nc(); }

#define ri1(a) int a = IO::_ni()
#define ri2(a, b) int a = IO::_ni(); int b = IO::_ni()
#define ri3(a, b, c) int a = IO::_ni(); int b = IO::_ni(); int c = IO::_ni()
#define ri4(a, b, c, d) int a = IO::_ni(); int b = IO::_ni(); int c = IO::_ni(); int d = IO::_ni()
#define rid1(a) int a = IO::_ni() - 1
#define rid2(a, b) int a = IO::_ni() - 1; int b = IO::_ni() - 1
#define rid3(a, b, c) int a = IO::_ni() - 1; int b = IO::_ni() - 1; int c = IO::_ni() - 1
#define rid4(a, b, c, d) int a = IO::_ni() - 1; int b = IO::_ni() - 1; int c = IO::_ni() - 1; int d = IO::_ni() - 1
#define rl1(a) ll a = IO::_nl()
#define rl2(a, b) ll a = IO::_nl(); ll b = IO::_nl()
#define rl3(a, b, c) ll a = IO::_nl(); ll b = IO::_nl(); ll c = IO::_nl()
#define rl4(a, b, c, d) ll a = IO::_nl(); ll b = IO::_nl(); ll c = IO::_nl(); ll d = IO::_nl()
#define rd1(a) db a = IO::_nf()
#define rd2(a, b) db a = IO::_nf(); db b = IO::_nf()
#define rd3(a, b, c) a = IO::_nf(); b = IO::_nf(); c = IO::_nf()
#define rd4(a, b, c, d) a = IO::_nf(); b = IO::_nf(); c = IO::_nf(), d = IO::_nf()
#define rc1(a) char a = IO::_nc()
#define rc2(a, b) char a = IO::_nc(); char b = IO::_nc()
#define rc3(a, b, c) char a = IO::_nc(); char b = IO::_nc(); char c = IO::_nc()
#define rc4(a, b, c, d) char a = IO::_nc(); char b = IO::_nc(); char c = IO::_nc(); char d = IO::_nc()
#define rs1(a) string a = IO::_ns()
#define rs2(a, b) string a = IO::_ns(); string b = IO::_ns()
#define rvi(a, n) vi a(n); FOR (i, n) IO::_ri(a[i])
#define rvid(a, n) vi a(n); FOR (i, n) IO::_ri(a[i]), a[i]--;
#define rvl(a, n) vl a(n); FOR (i, n) IO::_ri(a[i])
#define rvb(a, n) vb a(n); FOR (i, n) a[i] = (nxtc() == '1')

#define ri(...) VFUNC(ri, __VA_ARGS__)
#define rid(...) VFUNC(rid, __VA_ARGS__)
#define rl(...) VFUNC(rl, __VA_ARGS__)
#define rd(...) VFUNC(rd, __VA_ARGS__)
#define rc(...) VFUNC(rc, __VA_ARGS__)
#define rs(...) VFUNC(rs, __VA_ARGS__)

const int inf = 1e9;
const ll INF = 1e18;
const db eps = 1e-9;

vi make_perm(int n) { vi ret(n); iota(all(ret), 0); return ret; }
template<class T> bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

/*

swap the 2's to the end and the 0's to the start
using the 1's as a pivot

*/

struct Solver {

    void sovle() {
        ri(n);
        rvi(a, n);
        vi goal = a;
        sort(all(goal));
        set<int> zeroes, ones, twos;
        FOR (i, n) {
            if (a[i] == 0) zeroes.ins(i);
            else if (a[i] == 1) ones.ins(i);
            else twos.ins(i);
        }
        vpi out;
        while (true) {
            if (goal[*ones.begin()] == 0) {
                int i = *ones.begin();
                int j = *zeroes.rbegin();
                swap(a[i], a[j]);
                ones.erase(i);
                zeroes.erase(j);
                ones.ins(j);
                zeroes.ins(i);
                out.eb(i, j);
            } else if (goal[*ones.rbegin()] == 2) {
                int i = *ones.rbegin();
                int j = *twos.begin();
                swap(a[i], a[j]);
                ones.erase(i);
                twos.erase(j);
                ones.ins(j);
                twos.ins(i);
                out.eb(i, j);
            } else break;
        }
        println(size(out));
        each (i, j, out) println(i + 1, j + 1);
    }
};

main() {
    setfileaio("");
    setfile("");
    IO::initO();

    ri(t);
    FOR (i, t) {
        Solver solver {};
        solver.sovle();
    }
}

**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 the edge cases and scenarios where the code might fail. The code is supposed to sort the columns by the number of inscriptions (0, 1, or 2) using the allowed moves. The key points to consider are:

1. **Initial Configuration**: The initial configuration of the columns should be such that the sorting process is non-trivial.
2. **Edge Cases**: Consider scenarios where the columns are already sorted, or where there are very few columns to move.
3. **Maximizing Moves**: Create a configuration that requires a large number of moves to sort, but still within the constraints.

Given the constraints and the nature of the problem, a small-scale test input that could expose a bug might be:

- A configuration where the columns are almost sorted but require a few specific moves to be completely sorted.
- A configuration where the columns are in a pattern that might confuse the sorting logic.

Let's consider the following test input:

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

### Explanation:
- **Initial Configuration**: The columns are almost sorted but require a few specific moves to be completely sorted.
- **Expected Output**: The columns should be sorted in non-decreasing order.

### Steps to Sort:
1. Move the 2 from column 3 to column 4.
2. Move the 1 from column 4 to column 5.
3. Move the 1 from column 2 to column 1.

The expected output should be:
```plaintext
3
3 4
4 5
2 1
```

This test input is small and complete, and it should challenge the code to handle the sorting logic correctly. If the code fails to sort this configuration correctly, it will expose a bug in the logic.


**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:
t = int(input())
i= 0
while i < t:
    n = input()
    inputted = input().split(" ")
    columns = []
    for x in inputted:
        columns.append(int(x))
    moves = ""
    movecount = 0
    j = len(columns)-1
    while j > 0:
        v = 0
        while v < j:
            if columns[v] > columns[j]:
                movecount += 1
                if abs(columns[v]-columns[j]) == 1:
                    moves += str(v+1) + " " + str(j+1) + "\n"
                    columns[v] -= 1
                    columns[j] += 1
                else:
                    moves += str(v+1) + " " + str(columns.index(1)+1) + "\n"
                    columns[v] -= 1
                    columns[columns.index(1)] += 1
            v += 1
        j -= 1
    print(movecount)
    print(moves)
    t -= 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:
```plaintext
3
4
2 1 0 0
3
2 1 0
5
1 2 0 2 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:
def solve():
    n = int(input())
    arr = list(map(int, input().split()))
    ans = []
    cnt = [arr.count(a) for a in range(3)]
    k = 0
    L1 = []
    L2 = []
    for i, a in enumerate(arr):
        if a <= 1:
            if k < cnt[0] and a == 1:
                L1.append(i)
                arr[i] = 0
            if k >= cnt[0] and a == 0:
                L2.append(i)
                arr[i] = 1
            k += 1
    for i, j in zip(L1, L2):
        ans.append((i + 1, j + 1))
    k = 0
    L1 = []
    L2 = []
    for i, a in enumerate(arr):
        if a:
            if k < cnt[1] and a == 2:
                L1.append(i)
                arr[i] = 1
            if k >= cnt[1] and a == 1:
                L2.append(i)
                arr[i] = 2
            k += 1
    for i, j in zip(L1, L2):
        ans.append((i + 1, j + 1))
    k = 0
    L1 = []
    L2 = []
    for i, a in enumerate(arr):
        if a <= 1:
            if k < cnt[0] and a == 1:
                L1.append(i)
                arr[i] = 0
            if k >= cnt[0] and a == 0:
                L2.append(i)
                arr[i] = 1
            k += 1
    for i, j in zip(L1, L2):
        ans.append((i + 1, j + 1))
    if len(ans) <= n:
        print(len(ans))
        for i, j in ans:
            print(i, j)
        return
    ans = []
    k = 0
    L1 = []
    L2 = []
    for i, a in enumerate(arr):
        if a:
            if k < cnt[1] and a == 2:
                L1.append(i)
                arr[i] = 1
            if k >= cnt[1] and a == 1:
                L2.append(i)
                arr[i] = 2
            k += 1
    for i, j in zip(L1, L2):
        ans.append((i + 1, j + 1))
    k = 0
    L1 = []
    L2 = []
    for i, a in enumerate(arr):
        if a <= 1:
            if k < cnt[0] and a == 1:
                L1.append(i)
                arr[i] = 0
            if k >= cnt[0] and a == 0:
                L2.append(i)
                arr[i] = 1
            k += 1
    for i, j in zip(L1, L2):
        ans.append((i + 1, j + 1))
    k = 0
    L1 = []
    L2 = []
    for i, a in enumerate(arr):
        if a:
            if k < cnt[1] and a == 2:
                L1.append(i)
                arr[i] = 2
            if k >= cnt[1] and a == 1:
                L2.append(i)
                arr[i] = 1
            k += 1
    for i, j in zip(L1, L2):
        ans.append((i + 1, j + 1))
    if len(ans) <= n:
        print(len(ans))
        for i, j in ans:
            print(i, j)
        return

import sys
input = lambda: sys.stdin.readline().rstrip()
t = int(input())
for i 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
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:
import java.io.*;
import java.util.*;

public class Main {
    public static int INF = 0x3f3f3f3f, mod = 1000000007, mod9 = 998244353;
    public static void main(String args[]){
        try {
            PrintWriter o = new PrintWriter(System.out);
            boolean multiTest = true;
            // init
            if(multiTest) {
                int t = nextInt(), loop = 0;
                while (loop < t) {loop++;solve(o);}
            } else solve(o);
            o.close();
        } catch (Exception e) {e.printStackTrace();}
    }
    static void solve(PrintWriter o) {
        try {
            int n = nextInt();
            int[] a = new int[n];
            Integer[] b = new Integer[n];
            TreeSet<Integer>[] idx = new TreeSet[3];
            Arrays.setAll(idx, key->new TreeSet<>());
            for(int i=0;i<n;i++) {
                a[i] = nextInt(); // 0,1,2
                idx[a[i]].add(i);
                b[i] = a[i];
                idx[a[i]].add(i);
            }
            Arrays.sort(b);
            List<int[]> res = new ArrayList<>();
            for(int i=0;i<n;i++) {
                if(a[i] == b[i]) idx[a[i]].remove(i);
                else if(a[i] == b[i]+1) {
                    int fst = idx[b[i]].higher(i);
                    res.add(new int[]{i+1, fst+1});
                    idx[b[i]].remove(fst);
                    idx[b[i]].add(i);
                    idx[b[i]+1].remove(i);
                    idx[b[i]+1].add(fst);
                    a[i] = b[i];
                    a[fst] = b[i]+1;
                }
                else {
                    int fst = idx[b[i]+1].higher(i);
                    res.add(new int[]{i+1, fst+1});
                    idx[b[i]+2].remove(i);
                    idx[b[i]+2].add(fst);
                    idx[b[i]+1].remove(fst);
                    idx[b[i]+1].add(i);
                    a[i] = b[i]+1;
                    a[fst] = b[i]+2;
                    int snd = idx[b[i]].higher(i);
                    res.add(new int[]{i+1, snd+1});
                    idx[b[i]+1].remove(i);
                    idx[b[i]+1].add(snd);
                    idx[b[i]].remove(snd);
                    idx[b[i]].add(i);
                    a[i] = b[i];
                    a[snd] = b[i]+1;
                }
            }
            o.println(res.size());
            for(int[] it: res) o.println(it[0] + " " + it[1]);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static int lower_bound(Integer[] a, long val){
        int l = 0, r = a.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(a[mid] < val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int lower_bound(List<Integer> li, long val){
        int l = 0, r = li.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(li.get(mid) < val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int upper_bound(long[] preSum, long val){
        int l = 0, r = preSum.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(preSum[mid] <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int upper_bound(List<int[]> li, long val){
        int l = 0, r = li.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(li.get(mid)[0] <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int upper_bound(List<Integer> li, int val){
        int l = 0, r = li.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(li.get(mid) <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int upper_bound(int[] a, long val){
        int l = 0, r = a.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(a[mid] <= val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int lower_bound(List<int[]> li, int val){
        int l = 0, r = li.size();
        while(l < r){
            int mid = l + (r - l) / 2;
            if(li.get(mid)[0] < val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int lower_bound(int[] a, int val){
        int l = 0, r = a.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(a[mid] < val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static int lower_bound(long[][] a, long val){
        int l = 0, r = a.length;
        while(l < r){
            int mid = l + (r - l) / 2;
            if(a[mid][0] < val) l = mid + 1;
            else r = mid;
        }
        return l;
    }
    public static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a%b);
    }
    public static long[] extgcd(long a, long b) {
        if(b == 0) return new long[]{1, 0};
        long[] it = extgcd(b, a%b);
        long x = it[1], y = it[0];
        y -= a/b*x;
        return new long[]{x, y};
    }
    public static long lcm(long a, long b){
        return a / gcd(a,b)*b;
    }
    public static long qpow(long a, long n){
        long ret = 1l;
        while(n > 0){
            if((n & 1) == 1) ret = ret * a;
            n >>= 1;
            a = a * a;
        }
        return ret;
    }
    public static long qpow(long a, long n, int md){
        a %= md;
        long ret = 1l;
        while(n > 0){
            if((n & 1) == 1) ret = ret * a % md;
            n >>= 1;
            a = a * a % md;
        }
        return ret;
    }
    public static class FenWick {
        int n;
        long[] a;
        long[] tree;
        public FenWick(int n){
            this.n = n;
            a = new long[n+1];
            tree = new long[n+1];
        }
        private void add(int x, long val){
            while(x <= n){
                tree[x] += val;
                x += x&-x;
            }
        }
        private void addMx(int x, long val) {
            a[x] += val;
            tree[x] = a[x];
            while(x <= n) {
                for(int i=1;i<(x&-x);i<<=1) tree[x] = Math.max(tree[x], tree[x-i]);
                x += x&-x;
            }
        }
        private void addMn(int x, long val) {
            a[x] += val;
            tree[x] = a[x];
            while(x <= n) {
                for(int i=1;i<(x&-x);i<<=1) tree[x] = Math.min(tree[x], tree[x-i]);
                x += x&-x;
            }
        }
        private long query(int x){
            long ret = 0l;
            while(x > 0){
                ret += tree[x];
                x -= x&-x;
            }
            return ret;
        }
        private long queryMx(int l, int r) {
            long res = 0l;
            while(l <= r) {
                if(r-(r&-r) >= l) {
                    res = Math.max(res, tree[r]);
                    r -= r&-r;
                }
                else {
                    res = Math.max(res, a[r]);
                    r--;
                }
            }
            return res;
        }
        private long queryMn(int l, int r) {
            long res = 1l<<55;
            while(l <= r) {
                if(r-(r&-r) >= l) {
                    res = Math.min(res, tree[r]);
                    r -= r&-r;
                }
                else {
                    res = Math.min(res, a[r]);
                    r--;
                }
            }
            return res;
        }
    }
    static class Pair {
        Integer p1, p2;
        public Pair(Integer p1, Integer p2) {
            this.p1 = p1;
            this.p2 = p2;
        }
        @Override
        public int hashCode() {
            int prime = 31, ret = 0;
            ret = ret*prime+p1.hashCode();
            ret = ret*prime+p2.hashCode();
            return ret;
        }
        @Override
        public boolean equals(Object o) {
            if(o instanceof Pair pair) {
                return p1.equals(pair.p1) && p2.equals(pair.p2);
            }
            return false;
        }
    }
    static class DSU {
        int[] parent;
        int[] size;
        public DSU(int n) {
            parent = new int[n];
            size = new int[n];
            for(int i=0;i<n;i++) {
                parent[i] = i;
                size[i] = 1;
            }
        }
        public int find(int x) {
            if(parent[x] != x) parent[x] = find(parent[x]);
            return parent[x];
        }
        public void union(int x, int y) {
            int root_x = find(x);
            int root_y = find(y);
            if(root_x == root_y) return;
            parent[root_y] = root_x;
            size[root_x] += size[root_y];
            size[root_y] = 0;
        }
    }
    private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer tokenizer = new StringTokenizer("");
    private static String next() throws IOException{
        while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine());}
        return tokenizer.nextToken();
    }
    public static int nextInt() throws IOException {return Integer.parseInt(next());}
    public static Long nextLong() throws IOException {return Long.parseLong(next());}
    public static double nextDouble() throws IOException {return Double.parseDouble(next());}
    public static char nextChar() throws IOException {return next().toCharArray()[0];}
    public static String nextString() throws IOException {return next();}
    public static String nextLine() throws IOException {return reader.readLine();}
}

**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 edge cases and scenarios that can maximize the failure probability. Here are the steps to create such a test input:

1. **Identify the Bug**: The buggy code seems to have issues with handling the transition of inscriptions between columns, especially when there are multiple columns with the same number of inscriptions.

2. **Edge Cases**:
   - **Single Column**: A single column with a specific number of inscriptions.
   - **All Columns with the Same Number of Inscriptions**: This can cause issues if the code doesn't handle equal values correctly.
   - **Mixed Values**: A mix of 0, 1, and 2 inscriptions in a way that requires multiple moves to sort the columns.

3. **Test Input**:
   - **Test Case 1**: A single column with 1 inscription.
   - **Test Case 2**: Three columns with the same number of inscriptions (e.g., all 1s).
   - **Test Case 3**: A mix of 0, 1, and 2 inscriptions that requires multiple moves to sort.

Here is a small-scale test input that covers these edge cases:

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

This test input includes:
1. A single column with 1 inscription.
2. Three columns with 1 inscription each.
3. Four columns with a mix of 0, 2, 0, and 1 inscriptions, which requires multiple moves to sort.

This should help in exposing any issues in the buggy code, particularly in handling equal values and transitions between 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.*;

	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();
	            int[] arr = new int[n];
	            HashSet<Integer> ind0 = new HashSet<>();
	            HashSet<Integer> ind1 = new HashSet<>();
	            HashSet<Integer> ind2 = new HashSet<>();
	            int c0 = 0;
	            int c1 = 0;
	            int c2 = 0;

	            for (int i = 0; i < n; i++) {
	                int inp = sc.nextInt();
	                arr[i] = inp;
	                if(inp == 0) {
	                	c0++;
	                	ind0.add(i);
	                }else if(inp == 1) {
	                	c1++;
	                	ind1.add(i);
	                }else {
	                	c2++;
	                	ind2.add(i);
	                }
	            }

	            ArrayList<String> list = new ArrayList<String>();

	            for(int i=0; i<n; i++) {
	            	if(i<c0) {
	            		if(arr[i]==0) {
	            			ind0.remove(i);
	            		}else if(arr[i]==1) {
	            			int zind = ind0.iterator().next().intValue();
	            			ind1.remove(i);
	            			ind1.add(zind);
	            			ind0.remove(zind);
	            			arr[i] = 0;
	            			arr[zind] = 1;
	            			list.add((i+1) + " " + (zind+1));
	            		}else {
	            			int oind = ind1.iterator().next().intValue();
	            			ind2.remove(i);
	            			ind2.add(oind);
	            			ind1.remove(oind);
	            			int zind = ind0.iterator().next().intValue();
	            			ind1.add(zind);
	            			ind0.remove(zind);
	            			arr[i] = 0;
	            			arr[oind] = 2;
	            			arr[zind] = 1;
	            			list.add((i+1) + " " + (oind+1));
	            			list.add((i+1) + " " + (zind+1));
	            		}
	            	}else if(i>=c0 && i<c0+c1) {
	            		if(arr[i] == 1) {
	            			ind1.remove(i);
	            		}else if(arr[i]==0) {
	            			int oind = ind1.iterator().next().intValue();
	            			ind1.remove(oind);
	            			ind0.add(oind);
	            			ind0.remove(i);
	            			list.add((i+1) + " " + (oind+1));
	            			arr[i] = 1;
	            			arr[oind] =0;
	            		}else {
	            			int oind = ind1.iterator().next().intValue();
	            			ind1.remove(oind);
	            			ind2.add(oind);
	            			ind2.remove(i);
	            			list.add((i+1) + " " + (oind+1));
	            			arr[i] = 1;
	            			arr[oind] = 2;
	            		}
	            	}
	            }

	            System.out.println(list.size());
	            for (String s : list) {
	                System.out.println(s);
	            }
	        }

	        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 expose the bug in the provided code, we need to create a test case that triggers the faulty logic. The code seems to handle the initial distribution of columns with 0, 1, and 2 inscriptions, but there might be issues in the logic for moving inscriptions between columns.

### Step-by-Step Analysis:
1. **Initial Distribution**:
   - The code categorizes columns into three sets: `ind0`, `ind1`, and `ind2` for columns with 0, 1, and 2 inscriptions, respectively.
   - It also keeps track of the counts of each type of column.

2. **Moving Inscriptions**:
   - The code attempts to move inscriptions to sort the columns in non-decreasing order.
   - It iterates through the columns and tries to move inscriptions to achieve the desired order.

### Potential Issues:
1. **Handling of Initial State**:
   - The code might not handle the initial state correctly if the columns are already sorted or if there are multiple columns with the same number of inscriptions.

2. **Edge Cases**:
   - The code might fail if there are multiple columns with the same number of inscriptions and the logic for selecting the correct columns to move inscriptions is incorrect.
   - The code might also fail if the columns are already in a sorted order and no moves are needed.

### Challenging Test Case:
Let's create a test case where the columns are already in a sorted order, but the code might still try to perform unnecessary moves.

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

### Explanation:
1. **Test Case 1**:
   - Initial state: `0 1 1 2`
   - The columns are already in a sorted order, but the code might still try to perform moves.

2. **Test Case 2**:
   - Initial state: `0 1 2`
   - The columns are already in a sorted order, and no moves are needed.

3. **Test Case 3**:
   - Initial state: `0 1 1 1 2 2`
   - The columns are already in a sorted order, but the code might still try to perform moves due to the multiple columns with the same number of inscriptions.

This test case should expose any issues in the code where it unnecessarily performs moves or fails to recognize that the columns are already sorted.


**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:
// Solution by Abhi Jain aka Lucifer aka abhijain565aj
// Mera solution kyun dekh rha?? ... (｡◕‿‿◕｡)

// Template maine nhi banaya he pura, codeforces pe dusro k solutions se inspired template he ...
// Kudos to them ❤

#pragma GCC optimize("O3,unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> // find_by_order, order_of_key

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;

#define MOD 1000000007
#define INF 1e18

#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define v(x) vector<x>
#define nextL cout << "\n"

#define fo(i, n) for (decltype(n) i = 0; i < n; i++)
#define re(i, n) for (decltype(n) i = n - 1; i >= 0; i--)
#define fo1(i, a, b) for (decltype(b) i = a; i < b; i++)
#define re1(i, a, b) for (decltype(a) i = a; i >= b; i--)

#define YN(possible) cout << ((possible) ? "YES" : "NO") << endl;
#define all(x) (x).begin(), (x).end()
#define sortall(x) sort(all(x))
#define F first
#define S second
#define pb push_back
// a.resize(unique(all(a)) - a.begin());  -> unque element me convert karta hai

#define read(a, n)              \
    for (int i = 0; i < n; ++i) \
        cin >> a[i];
#define print_space(a, n)         \
    for (int i = 0; i < n; ++i)   \
        if (i == n - 1)           \
            cout << a[i] << "\n"; \
        else                      \
            cout << a[i] << ' ';
#ifndef ONLINE_JUDGE
#include "./0_debug.cpp"
#else
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define test(tt)
#define printTC(tc)
#endif

// min_max functions
template <typename T>
T max3(T a, T b, T c)
{
    return max(a, max(b, c));
}
template <typename T>
T max4(T a, T b, T c, T d)
{
    return max(max(a, d), max(b, c));
}
template <typename T>
T min3(T a, T b, T c)
{
    return min(a, min(b, c));
}
template <typename T>
T min4(T a, T b, T c, T d)
{
    return min(min(a, d), min(b, c));
}

/*
|     /\     |  _ \  | |  | | |_   _| ( )          / ____|  / __ \  |  __ \  |  ____| |
|    /  \    | |_) | | |__| |   | |   |/   ___    | |      | |  | | | |  | | | |__    |
|   / /\ \   |  _ <  |  __  |   | |       / __|   | |      | |  | | | |  | | |  __|   |
|  / ____ \  | |_) | | |  | |  _| |_      \__ \   | |____  | |__| | | |__| | | |____  |
| /_/    \_\ |____/  |_|  |_| |_____|     |___/    \_____|  \____/  |_____/  |______| |
*/
void solve()
{
    int n;
    cin >> n;
    vi a(n);
    read(a, n);
    debug(a);
    v(pii) moves;
    int ind = 0;
    fo(i, n)
    {
        if (a[i] == 1)
        {
            ind = i;
            break;
        }
    }
    auto sp = [&](int i, int j)
    {
        int lp = 0;
        int rp = n - 1;
        while (true)
        {
            while (lp < n && a[lp] != j)
                lp++;
            while (rp >= 0 && a[rp] != i)
                rp--;
            if (lp < rp)
            {
                swap(a[ind], a[rp]);
                moves.pb({ind, rp});
                swap(a[lp], a[rp]);
                moves.pb({lp, rp});
                ind = lp;
            }
            else
                break;
        };
    };
    auto sp1 = [&](int i, int j)
    {
        int lp = 0;
        int rp = n - 1;
        while (true)
        {
            while (lp < n && a[lp] != j)
                lp++;
            while (rp >= 0 && a[rp] != i)
                rp--;
            if (lp < rp)
            {
                swap(a[lp], a[rp]);
                moves.pb({lp, rp});
            }
            else
                break;
        };
    };
    sp(0, 2);
    sp1(0, 1);
    sp1(1, 2);
    debug(a);
    cout << moves.size() << endl;
    for (auto [i, j] : moves)
    {
        cout << i + 1 << ' ' << j + 1 << endl;
    }
}
/*
|   _____    ____    _____    ______     ______   _   _   _____     _____
|  / ____|  / __ \  |  __ \  |  ____|   |  ____| | \ | | |  __ \   / ____| |
| | |      | |  | | | |  | | | |__      | |__    |  \| | | |  | | | (___   |
| | |      | |  | | | |  | | |  __|     |  __|   | . ` | | |  | |  \___ \  |
| | |____  | |__| | | |__| | | |____    | |____  | |\  | | |__| |  ____) | |
|  \_____|  \____/  |_____/  |______|   |______| |_| \_| |_____/  |_____/  |
*/
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("./0_Error.txt", "w", stderr);
#endif
    int testCases = 1;
    cin >> testCases;
    fo(tt, testCases)
    {
        test(tt + 1);
#ifndef ONLINE_JUDGE
        // printTC(tt + 1);
#endif
        solve();
    }
#ifndef ONLINE_JUDGE
    cerr << "------------------------------------------\n";
#endif
}

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

### Explanation:
1. **First Test Case:**
   - **Input:** `4\n0 2 0 1`
   - **Expected Output:** The columns should be rearranged to `0 0 1 2` using the minimum number of moves. The moves are:
     - Move 1: Swap inscriptions between columns 2 and 4 (2 and 1).
     - Move 2: Swap inscriptions between columns 2 and 3 (2 and 0).
   - **Output:**
     ```
     2
     2 4
     2 3
     ```

2. **Second Test Case:**
   - **Input:** `3\n1 2 0`
   - **Expected Output:** The columns should be rearranged to `0 1 2` using the minimum number of moves. The moves are:
     - Move 1: Swap inscriptions between columns 3 and 1 (0 and 1).
     - Move 2: Swap inscriptions between columns 2 and 3 (2 and 0).
   - **Output:**
     ```
     2
     3 1
     2 3
     ```

3. **Third Test Case:**
   - **Input:** `6\n0 1 1 2 2 2`
   - **Expected Output:** The columns are already in non-decreasing order, so no moves are needed.
   - **Output:**
     ```
     0
     ```

These test cases are designed to cover different scenarios, including:
- Columns with different initial configurations.
- Columns that are already in the correct order.
- Columns that require multiple moves to be sorted.

By using these test cases, we can effectively expose any bugs in the given buggy code.


**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>
using namespace std;
#define ll long long
#define ld long double
#define nl "\n"
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<pair<ll,ll>> vpll;
#define pb push_back
#define Sort(a) sort(a.begin(),a.end())
#define all(x) (x).begin(), (x).end()
const ll f = 1e9+7;

void solve(){
    int n;
    cin>>n;
    set<int> s[3];

    vi v(n);

    for(int i=0;i<n;i++){
        cin>>v[i];
        s[v[i]].insert(i);
    }
    vi vcpy=v;

    vi v2=v;
    Sort(v2);

    vector<pii> moves;
    auto it=s[0].begin();
    for(int i=0;i<n;i++){
        if(v[i]==0){
            ++it;
            continue;
        }
        if(v2[i]!=0)break;
        else{
            if(v[i]==1){
                s[1].erase(s[1].begin());
                s[1].insert(*it);
                swap(v[*it],v[i]);
                // cout<<*it<<" "<<i<<nl;
                moves.pb({*it,i});

                ++it;
            }
            else{
                s[2].erase(s[2].begin());
                s[2].insert(*s[1].begin());
                swap(v[i],v[*s[1].begin()]);
                moves.pb({*s[1].begin(),i});
                s[1].erase(s[1].begin());
                s[1].insert(*it);
                swap(v[*it],v[i]);
                moves.pb({*it,i});

                ++it;
            }
        }

    }
    for(int i=0;i<n;i++){
        if(v[i]==v2[i]){
            s[v[i]].erase(i);
        }
    }
    for(int i=0;i<n;i++){
        if(v[i]!=v2[i]){
            // cout<<i<<" xx "<<v[i]<<nl;
            moves.pb({i,*s[v2[i]].begin()});
            s[v[i]].erase(i);

            //
            swap(v[i],v[*s[v2[i]].begin()]);
            s[v2[i]].erase(s[v2[i]].begin());
        }
    }
    if(moves.size()<=n){
        cout<<moves.size()<<nl;
        for(auto z:moves){
            cout<<z.first+1<<" "<<z.second+1<<nl;
        }
        return;

    }
    else{
        v=vcpy;
        s[0].clear();
        s[1].clear();
        s[2].clear();
        for(int i=0;i<n;i++){
            s[v[i]].insert(i);
        }
        moves.clear();
        auto it=s[2].begin();
        for(int i=n-1;i>=0;i--){
            if(v[i]==2){
                ++it;
                continue;
            }
            if(v2[i]!=2)break;
            else{
                if(v[i]==1){
                    s[1].erase(s[1].begin());
                    s[1].insert(*it);
                    swap(v[*it],v[i]);
                    // cout<<*it<<" "<<i<<nl;
                    moves.pb({*it,i});

                    ++it;
                }
                else{
                    s[0].erase(i);
                    s[0].insert(*s[1].begin());
                    swap(v[i],v[*s[1].begin()]);
                    moves.pb({*s[1].begin(),i});
                    s[1].erase(s[1].begin());
                    s[1].insert(*it);
                    swap(v[*it],v[i]);
                    moves.pb({*it,i});

                    ++it;
                }
            }

        }
        for(int i=0;i<n;i++){
            if(v[i]==v2[i]){
                s[v[i]].erase(i);
            }
        }
        // cout<<s[0].size()<<" "<<s[1].size()<<nl;
        for(int i=0;i<n;i++){
            if(v[i]!=v2[i]){
                // cout<<i<<" "<<v2[i]<<nl;
                moves.pb({i,*s[v2[i]].begin()});
                //
                s[v[i]].erase(i);
                swap(v[i],v[*s[v2[i]].begin()]);
                //
                s[v2[i]].erase(s[v2[i]].begin());
            }
        }
        cout<<moves.size()<<nl;
        for(auto z:moves){
            cout<<z.first+1<<" "<<z.second+1<<nl;
        }
        return;
    }

}

int 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 provided code, we need to consider edge cases or scenarios that might cause the algorithm to fail. The key points to focus on are:

1. **Initial Configuration**: The initial configuration of the columns should be such that the algorithm might have difficulty in correctly sorting the columns.
2. **Edge Cases**: Scenarios where the columns are already sorted or nearly sorted, or where the number of inscriptions is distributed in a way that might confuse the algorithm.
3. **Special Cases**: Cases where the number of columns is small (e.g., 1 or 2), or where the number of inscriptions is all 0s, 1s, or 2s.

Let's consider a small-scale test input that might expose the bug:

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

### Explanation
1. **First Test Case**: `4 1 2 0 1`
   - Initial state: `1, 2, 0, 1`
   - This configuration has a mix of 0s, 1s, and 2s, and the algorithm should be able to sort it. However, the presence of multiple 1s and 2s might cause issues if the algorithm incorrectly handles the swaps.

2. **Second Test Case**: `3 2 1 0`
   - Initial state: `2, 1, 0`
   - This configuration is in reverse order. The algorithm should be able to sort it, but it might fail if it does not handle the reverse order correctly.

3. **Third Test Case**: `6 0 1 2 0 1 2`
   - Initial state: `0, 1, 2, 0, 1, 2`
   - This configuration is already sorted. The algorithm should output 0 moves, but it might still attempt to make unnecessary moves if it is not correctly handling already sorted cases.

These test cases are designed to be small and manageable while still being challenging enough to potentially expose the bug in the provided code.


**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 sys
for t in range(int(sys.stdin.readline())):
    n=int(sys.stdin.readline())
    a=[int(i) for i in sys.stdin.readline().split()]
    b=sorted(a)
    one=set()
    two=[]
    c=0
    moves=[]
    for i in range(n):
        if a[i]==1:
            one.add(i)
        elif a[i]!=b[i] and a[i]==2:
            two.append(i)
    while two:
        while a:
            if a[-1]==2:
                a.pop()
            else:
                break
        if len(a)-1 not in one:
            x=one.pop()
            a[x]=0
            c+=1
            moves.append(str(x+1)+" "+str(len(a)))
        else:
            one.remove(len(a)-1)
        one.add(two[-1])
        a[two[-1]]=1
        c+=1
        moves.append(str(two.pop()+1)+" "+str(len(a)))
        a.pop()
    bruh=[]
    for i in one:
        if b[i]!=1:
            bruh.append(i)
    while bruh:
        while a:
            if a[-1]==1:
                a.pop()
            else:
                break
        c+=1
        moves.append(str(bruh.pop()+1)+" "+str(len(a)))
        a.pop()
    print(c)
    for i in moves:
        print(i)

**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 1 2 1 0
```

### Explanation:

1. **Test Case 1:**
   - Initial: `0 2 0 1`
   - This is a straightforward case where the columns can be sorted by moving the inscriptions from the column with 2 inscriptions to the columns with 0 inscriptions. The expected output is 2 moves.

2. **Test Case 2:**
   - Initial: `1 2 0`
   - This case is also straightforward, where the column with 2 inscriptions should be moved to the column with 0 inscriptions. The expected output is 2 moves.

3. **Test Case 3:**
   - Initial: `2 1 2 1 0`
   - This is a more complex case where there are multiple columns with 2 inscriptions and 1 inscription. The goal is to sort the columns such that the number of inscriptions is non-decreasing. The expected output is 4 moves, but the buggy code might fail to handle this case correctly, especially if it does not manage the set and list operations correctly.

These test cases are designed to challenge the buggy code by testing its ability to handle multiple columns with the same number of inscriptions and ensuring that the columns are sorted correctly.


**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 math import ceil,log,lcm,gcd,isfinite
#from collections import deque
#from bisect import bisect #bisect:>num ka index(0-based)
#from heapq import heappush,heappop
#from sortedcontainers import SortedList,SortedSet,SortedDict
#from random import randint

from sys import stdin,stdout
input=lambda:stdin.readline().rstrip()
print=lambda *args,sep=' ',end='\n':stdout.write(sep.join(map(str,args))+end)

def out(l):
    print('\n'.join(map(lambda x:str(x[0])+' '+str(x[1]),l)))

def yes():
    print('YES')

def no():
    print('NO')

def alice():
    print('ALICE')

def bob():
    print('BOB')

def solve():
    n=int(input())
    a=list(map(int,input().split()))
    cnt=[0]*3
    for j in a:
        cnt[j]+=1
    start=cnt[0]
    end=start+cnt[1]-1
    extra01,extra02=[],[]
    extra20,extra21=[],[]
    ans=[]
    for i in range(start):
        if a[i]==1:
            extra01.append(i)
        elif a[i]==2:
            extra02.append(i)
    for i in range(end+1,n):
        if a[i]==0:
            extra20.append(i)
        elif a[i]==1:
            extra21.append(i)
    #print(start,end)
    for i in range(start,end+1):
        if a[i]==1:
            continue
        elif a[i]==2:
            if not extra21:
                ele1=extra01.pop()
                ele2=extra20.pop()
                a[ele1],a[ele2]=a[ele2],a[ele1]
                extra21.append(ele2)
                ans.append((ele1+1,ele2+1))
            ele=extra21.pop()
            temp=a[ele]
            a[ele]=2
            a[i]=temp
            ans.append((i+1,ele+1))
        else:
            if not extra01:
                ele1=extra21.pop()
                ele2=extra02.pop()
                a[ele1],a[ele2]=a[ele2],a[ele1]
                extra01.append(ele2)
                ans.append((ele1+1,ele2+1))
            ele=extra01.pop()
            temp=a[ele]
            a[ele]=0
            a[i]=temp
            ans.append((i+1,ele+1))
    #print(a)
    print(len(ans))
    out(ans)

for _ in range(int(input())):
    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 generate a challenging test input that exposes the bug in the provided code, we need to focus on edge cases and scenarios that might cause the algorithm to fail. Here are some potential edge cases to consider:

1. **Single Column with One Inscription:**
   - This is the simplest case and should be handled correctly, but it's a good starting point.

2. **All Columns with the Same Number of Inscriptions:**
   - This can be tricky if the code doesn't handle uniform distributions well.

3. **Columns with a Large Number of Zeros and Twos:**
   - This can expose issues with how the code handles the transfer of inscriptions.

4. **Columns with a Large Number of Ones:**
   - This can test how the code handles the distribution of ones.

5. **Columns with a Mixture of Zeros, Ones, and Twos:**
   - This can test the overall logic and edge cases in the algorithm.

Given the constraints and the need for a small-scale test input, let's focus on a mixture of zeros, ones, and twos that can potentially expose the bug.

### Challenging Test Input

```plaintext
1
6
0 1 2 2 0 1
```

### Explanation

- **Initial State:**
  - Columns: 0, 1, 2, 2, 0, 1
- **Expected Output:**
  - The columns should be sorted in non-decreasing order of inscriptions.
  - Possible final state: 0, 0, 1, 1, 2, 2
- **Steps to Sort:**
  - Move 1: Transfer one inscription from column 3 to column 1 (2 -> 1)
  - Move 2: Transfer one inscription from column 4 to column 1 (2 -> 1)
  - Move 3: Transfer one inscription from column 2 to column 5 (1 -> 0)
  - Move 4: Transfer one inscription from column 2 to column 5 (1 -> 0)
  - Move 5: Transfer one inscription from column 2 to column 6 (1 -> 1)

This test input is designed to challenge the code by requiring multiple moves to balance the inscriptions and achieve the sorted order. It includes a mix of zeros, ones, and twos, which can help expose any issues in the logic for transferring 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:
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.PriorityQueue;
import java.lang.StringBuilder;

public class Main {

    public static int gcd(int a, int b) {
        if (b==0) return a;
        return gcd(b,a%b);
     }

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

        int numTests = Integer.parseInt(s.nextLine());

        // 100 and 102
        for(int j = 0; j < numTests; j++) {
            int n = Integer.parseInt(s.nextLine());
            String[] line = s.nextLine().split(" ");
            int[] l = new int[line.length];
            PriorityQueue<Integer> lowest1s = new PriorityQueue<>();
            PriorityQueue<Integer> lowest2s = new PriorityQueue<>();
            PriorityQueue<Integer> highest0s = new PriorityQueue<>((x, y) -> Integer.compare(y, x));
            PriorityQueue<Integer> highest1s = new PriorityQueue<>((x, y) -> Integer.compare(y, x));
            for(int i = 0; i < l.length; i++) {
                l[i] = Integer.parseInt(line[i]);
                if(l[i] == 0) {
                    highest0s.add(i);
                } else if(l[i] == 1) {
                    highest1s.add(i);
                    lowest1s.add(i);
                } else if(l[i] == 2) {
                    lowest2s.add(i);
                }
            }

            StringBuilder sb = new StringBuilder();
            int numSwaps = 0;
            while(lowest1s.size() > 0 && highest0s.size() > 0 && highest0s.peek() > lowest1s.peek()) {
                // swap here
                int h0 = highest0s.poll();
                int l1 = lowest1s.poll();
                sb.append((l1+1) + " " + (h0+1) + "\n");
                lowest1s.add(h0);
                highest1s.add(h0);
                highest0s.add(l1);
                numSwaps++;
            }

            while(highest1s.size() > 0 && lowest2s.size() > 0 && highest1s.peek() > lowest2s.peek()) {
                // swap here
                int h1 = highest1s.poll();
                int l2 = lowest2s.poll();
                sb.append((l2+1) + " " + (h1+1) + "\n");
                lowest2s.add(h1);
                highest1s.add(l2);
                lowest1s.add(l2);
                numSwaps++;
            }

            while(lowest1s.size() > 0 && highest0s.size() > 0 && highest0s.peek() > lowest1s.peek()) {
                // swap here
                int h0 = highest0s.poll();
                int l1 = lowest1s.poll();
                sb.append((l1+1) + " " + (h0+1) + "\n");
                lowest1s.add(h0);
                highest1s.add(h0);
                highest0s.add(l1);
                numSwaps++;
            }

            while(highest1s.size() > 0 && lowest2s.size() > 0 && highest1s.peek() > lowest2s.peek()) {
                // swap here
                int h1 = highest1s.poll();
                int l2 = lowest2s.poll();
                sb.append((l2+1) + " " + (h1+1) + "\n");
                lowest2s.add(h1);
                highest1s.add(l2);
                lowest1s.add(l2);
                numSwaps++;
            }

            System.out.println(numSwaps);
            System.out.print(sb.toString());
        }

    }

}

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

**Explanation:**

1. **Test Case 1:**
   - Initial columns: `2 1 0 0`
   - This case is designed to test the handling of multiple `0` columns and the need to balance the `2` column with the `1` column before sorting the `0` columns.

2. **Test Case 2:**
   - Initial columns: `0 1 2`
   - This is a simple case to ensure the basic functionality of the algorithm. It should sort the columns in one move.

3. **Test Case 3:**
   - Initial columns: `1 1 1 2 0`
   - This case tests the handling of multiple `1` columns and a single `2` column. The algorithm should be able to balance the `2` column with one of the `1` columns and then sort the remaining `1` and `0` columns.

These test cases are designed to expose potential issues in the buggy code, particularly in handling multiple columns with the same height and ensuring that the columns are sorted correctly.


**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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        AReader sc = new AReader();
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            solve(sc);
        }
    }

    public static void solve(AReader sc) {
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        TreeMap<Integer, List<Integer>> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = a[i];
            map.computeIfAbsent(a[i], v -> new ArrayList<>()).add(i);
        }
        Arrays.sort(b);
        List<int[]> list = new ArrayList<>();
        for (int i = n - 1; i >= 0; i--) {
            int d = b[i] - a[i];
            while (d > 0) {
                Map.Entry<Integer, List<Integer>> entry = map.higherEntry(a[i]);
                Integer key = entry.getKey();
                List<Integer> ids = entry.getValue();
                while (ids.getLast() > i) {
                    ids.removeLast();
                }
                Integer last = ids.removeLast();
                a[last] -= 1;
                map.computeIfAbsent(a[last], v -> new ArrayList<>()).add(last);
                a[i] += 1;
                list.add(new int[]{last + 1, i + 1});
                d -= 1;
            }
        }
        System.out.println(list.size());
        for (int[] ints : list) {
            System.out.println(ints[0] + " " + ints[1]);
        }
    }

    static class AReader {
        private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer tokenizer = new StringTokenizer("");

        private String innerNextLine() {
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {
                String nextLine = innerNextLine();
                if (nextLine == null) {
                    return false;
                }
                tokenizer = new StringTokenizer(nextLine);
            }
            return true;
        }

        public String nextLine() {
            tokenizer = new StringTokenizer("");
            return innerNextLine();
        }

        public String next() {
            hasNext();
            return tokenizer.nextToken();
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }
// public BigInteger nextBigInt() {
// return new BigInteger(next());
// }
// 若需要nextDouble等方法，请自行调用Double.parseDouble包装
    }
}

**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 that can cause the algorithm to fail. Here are the steps to create such a test input:

1. **Identify Potential Bugs**:
   - The code uses a `TreeMap` to keep track of the indices of columns with the same number of inscriptions.
   - It sorts the array `b` to determine the target number of inscriptions for each column.
   - The code then tries to move inscriptions to achieve the sorted order.

2. **Edge Cases to Consider**:
   - **Single Column**: A test case with only one column.
   - **All Columns with 1 Inscription**: A test case where all columns have exactly 1 inscription.
   - **All Columns with 0 or 2 Inscriptions**: A test case where all columns have either 0 or 2 inscriptions.
   - **Alternating Inscriptions**: A test case with alternating 0 and 1 inscriptions.
   - **Large Number of Columns**: A test case with a large number of columns to ensure the algorithm handles it within the time and memory limits.

3. **Small-Scale Test Input**:
   - We will create a test case with a small number of columns to ensure it is easy to verify and does not exceed the output length limit.

4. **Chosen Test Input**:
   - **Test Case 1**: A single column with 1 inscription.
   - **Test Case 2**: Three columns with inscriptions 0, 1, 2.
   - **Test Case 3**: Four columns with inscriptions 0, 2, 0, 1 (similar to the example provided).

Here is the test input:

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

This test input includes:
- A single column with 1 inscription (edge case).
- A small set of columns with inscriptions 0, 1, 2 (general case).
- A small set of columns with inscriptions 0, 2, 0, 1 (similar to the provided example but still challenging).

This should help expose any issues in the buggy code, especially in handling small and edge cases.