#include <bits/stdc++.h>
using namespace std;
int DP[16][16][1 << 15];
pair<int, int> track[16][16][1 << 15];
int sum[1 << 15];
int a[15];
int N;
void show(int state) {
  for (int i = 0; i < N; ++i) {
    if ((1 << i) & state)
      cout << 1;
    else
      cout << 0;
  }
  cout << endl;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) scanf("%d", &a[i]);
    for (int s = 0; s < (1 << N); ++s) {
      sum[s] = 0;
      for (int i = 0; i < N; ++i) {
        if ((1 << i) & s) {
          sum[s] += a[i];
        }
      }
    }
    for (int i = 0; i <= N; ++i) {
      for (int j = 0; j <= N; ++j) {
        for (int s = 0; s < (1 << N); ++s) {
          DP[i][j][s] = 1000000000;
          track[i][j][s] = make_pair(-1, -1);
        }
      }
    }
    DP[0][0][0] = 0;
    for (int cnt = 0; cnt < N; ++cnt) {
      for (int pos = 0; pos < N; ++pos) {
        for (int chosen = 0; chosen < (1 << N); ++chosen) {
          if (DP[cnt][pos][chosen] < 1000000000) {
            int not_chosen = chosen ^ ((1 << N) - 1);
            for (int choose = not_chosen; choose;
                 choose = (choose - 1) & not_chosen) {
              if (sum[choose] <= DP[cnt][pos][chosen]) continue;
              if ((choose >> pos) == 0) continue;
              int npos = pos + 1 + __builtin_ctz(choose >> pos);
              if (DP[cnt + 1][npos][chosen | choose] > sum[choose]) {
                DP[cnt + 1][npos][chosen | choose] = sum[choose];
                track[cnt + 1][npos][chosen | choose] = make_pair(pos, chosen);
              }
            }
          }
        }
      }
    }
    int bcnt = -1, bpos = -1, bmask = (1 << N) - 1;
    for (int cnt = 0; cnt <= N; ++cnt) {
      for (int pos = 0; pos <= N; ++pos) {
        if (DP[cnt][pos][(1 << N) - 1] < 1000000000) {
          bcnt = cnt;
          bpos = pos;
        }
      }
    }
    vector<pair<int, int> > ret;
    for (; bcnt >= 1; --bcnt) {
      int npos = track[bcnt][bpos][bmask].first;
      int nmask = track[bcnt][bpos][bmask].second;
      for (int i = 0; i < N; ++i) {
        if ((bmask ^ nmask) & (1 << i)) {
          if (i != bpos - 1) {
            ret.emplace_back(i, bpos - 1);
          }
        }
      }
      bpos = npos;
      bmask = nmask;
    }
    printf("%d\n", (int)ret.size());
    for (int i = 0; i < (int)ret.size(); ++i) {
      int x = ret[i].first;
      int y = ret[i].second;
      for (int j = 0; j < i; ++j) {
        if (ret[j].first < ret[i].first) --x;
        if (ret[j].first < ret[i].second) --y;
      }
      printf("%d %d\n", x + 1, y + 1);
    }
  }
}
