#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int N = 15;
int n;
int a[N];
int sum[1 << N];
int dp[N + 1][1 << N][N + 1];
pair<int, int> p[N + 1][1 << N][N + 1];
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < int(n); ++i) scanf("%d", &a[i]);
  for (int mask = 0; mask < int(1 << n); ++mask) {
    sum[mask] = 0;
    for (int i = 0; i < int(n); ++i)
      if (mask & (1 << i)) sum[mask] += a[i];
  }
  for (int cnt = 0; cnt < int(n + 1); ++cnt)
    for (int mask = 0; mask < int(1 << n); ++mask)
      for (int pos = 0; pos < int(n + 1); ++pos) dp[cnt][mask][pos] = INF;
  dp[0][0][0] = 0;
  for (int cnt = 0; cnt < int(n); ++cnt)
    for (int mask = 0; mask < int(1 << n); ++mask)
      for (int pos = 0; pos < int(n); ++pos)
        if (dp[cnt][mask][pos] < INF) {
          int rmask = mask ^ ((1 << n) - 1);
          for (int nmask = rmask; nmask; nmask = (nmask - 1) & rmask) {
            if (sum[nmask] <= dp[cnt][mask][pos]) continue;
            if ((nmask >> pos) == 0) continue;
            int npos = pos + __builtin_ctz(nmask >> pos) + 1;
            if (dp[cnt + 1][mask | nmask][npos] > sum[nmask]) {
              dp[cnt + 1][mask | nmask][npos] = sum[nmask];
              p[cnt + 1][mask | nmask][npos] = make_pair(mask, pos);
            }
          }
        }
  int acnt = 0, apos = 0;
  for (int cnt = 0; cnt < int(n + 1); ++cnt)
    for (int pos = 0; pos < int(n + 1); ++pos)
      if (dp[cnt][(1 << n) - 1][pos] < INF) acnt = cnt, apos = pos;
  vector<pair<int, int> > ans;
  int mask = (1 << n) - 1, pos = apos;
  for (int cnt = acnt; cnt > 0; --cnt) {
    int nmask = p[cnt][mask][pos].first;
    int npos = p[cnt][mask][pos].second;
    for (int i = 0; i < int(n); ++i)
      if ((nmask ^ mask) & (1 << i))
        if (i != pos - 1) ans.push_back(make_pair(i, pos - 1));
    mask = nmask, pos = npos;
  }
  printf("%d\n", int((ans).size()));
  for (int i = 0; i < int(int((ans).size())); ++i) {
    int from = ans[i].first;
    for (int j = 0; j < int(i); ++j) from -= ans[j].first < ans[i].first;
    int to = ans[i].second;
    for (int j = 0; j < int(i); ++j) to -= ans[j].first < ans[i].second;
    printf("%d %d\n", from + 1, to + 1);
  }
}
int main() {
  int tc;
  scanf("%d", &tc);
  for (int i = 0; i < int(tc); ++i) solve();
}
