#include <bits/stdc++.h>
using namespace std;
const int N = 15;
int ans[N], mid[N], sum[1 << N];
vector<int> v;
bool dfs(int p, int s, int n) {
  if (p == n) {
    for (int i = 0; i < n; ++i) ans[i] = mid[i];
    ans[n - 1] |= s;
    return 1;
  }
  if (v[p] > v[p - 1]) {
    mid[p] = 0;
    if (dfs(p + 1, s, n)) return 1;
  }
  for (int i = s; i > 0; i = ((i - 1) & s))
    if (v[p] + sum[i] > v[p - 1]) {
      v[p] += sum[i];
      mid[p] = i;
      if (dfs(p + 1, s ^ i, n)) return 1;
      v[p] -= sum[i];
    }
  return 0;
}
void solve(int n) {
  vector<vector<int>> bt(n);
  for (int i = 0; i < (1 << n) - 1; ++i) bt[__builtin_popcount(i)].push_back(i);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int b = 0; b < n; ++b)
    for (int s : bt[b]) {
      vector<int> vec;
      vector<int> id[2];
      v.clear();
      int nl = 0, nr = 0;
      for (int i = 0; i < n; ++i) {
        int t = (s >> i) & 1;
        if (t)
          vec.push_back(a[i]), ++nr;
        else
          v.push_back(a[i]), ++nl;
        id[t].push_back(i + 1);
      }
      for (int i = 0; i < 1 << nr; ++i) {
        sum[i] = 0;
        for (int j = 0; j < nr; ++j)
          if ((i >> j) & 1) sum[i] += vec[j];
      }
      if (!dfs(1, (1 << nr) - 1, nl)) continue;
      cout << nr << ('\n');
      for (int i = 0; i < nl; ++i)
        for (int j = 0; j < nr; ++j)
          if ((ans[i] >> j) & 1) {
            cout << id[1][j] << ' ' << id[0][i] << ('\n');
            for (int k = 0; k < 2; ++k)
              for (int &l : id[k]) l -= l > id[1][j];
          }
      return;
    }
}
int main() {
  int QAQ, n;
  for (cin >> QAQ; QAQ; QAQ--) cin >> n, solve(n);
}
