#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int dp[16][1 << 15][16];
pair<int, int> p[16][1 << 15][16];
int sum[1 << 15];
void solve() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i <= N; i++)
    for (int j = 0; j < (1 << N); j++)
      for (int k = 0; k <= N; k++) dp[i][j][k] = INT_MAX;
  dp[0][0][0] = 0;
  sum[0] = 0;
  for (int mask = 0; mask < 1 << N; mask++) {
    sum[mask] = 0;
    for (int j = 0; j < N; j++) {
      if ((1 << j) & mask) sum[mask] += A[j];
    }
  }
  for (int i = 0; i <= N; i++) {
    for (int mask = 0; mask < (1 << N); mask++) {
      for (int pos = 0; pos <= N; pos++) {
        if (dp[i][mask][pos] == INT_MAX) continue;
        int rmask = (1 << N) - 1 - mask;
        if (sum[rmask] <= dp[i][mask][pos]) continue;
        for (int t = rmask; t; t = (t - 1) & rmask) {
          if (sum[t] <= dp[i][mask][pos]) continue;
          if (t >> pos == 0) continue;
          int npos = pos + __builtin_ctz(t >> pos) + 1;
          if (sum[t] < dp[i + 1][mask | t][npos]) {
            dp[i + 1][mask | t][npos] = min(dp[i + 1][mask | t][npos], sum[t]);
            p[i + 1][mask | t][npos] = {mask, pos};
          }
        }
      }
    }
  }
  int tcnt = 1;
  int tpos = 1;
  for (int cnt = 0; cnt <= N; cnt++) {
    for (int pos = 0; pos <= N; pos++) {
      if (dp[cnt][(1 << N) - 1][pos] != INT_MAX) {
        tcnt = cnt;
        tpos = pos;
      }
    }
  }
  vector<pair<int, int>> op;
  int mask = (1 << N) - 1;
  while (tcnt > 0) {
    int lastM;
    int lastP;
    tie(lastM, lastP) = p[tcnt][mask][tpos];
    int rmask = mask ^ lastM;
    for (int j = 0; j < N; j++) {
      if (j == tpos - 1) continue;
      if (rmask & (1 << j)) {
        op.push_back({j, tpos - 1});
      }
    }
    tcnt--;
    tpos = lastP;
    mask = lastM;
  }
  reverse(op.begin(), op.end());
  cout << op.size() << "\n";
  vector<int> idx(N);
  for (int i = 0; i < N; i++) idx[i] = i;
  for (int i = 0; i < op.size(); i++) {
    cout << idx[op[i].first] + 1 << " " << idx[op[i].second] + 1 << "\n";
    for (int j = op[i].first + 1; j < N; j++) idx[j]--;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);
  int T = 1;
  cin >> T;
  for (int i = 1; i <= T; i++) {
    solve();
  }
  cout.flush();
  return 0;
}
