#include <bits/stdc++.h>
using namespace std;
const int maxn = 16;
int n;
int a[maxn];
int sum[1 << maxn];
int f[maxn][maxn][1 << maxn];
pair<pair<int, int>, int> g[maxn][maxn][1 << maxn];
int T;
inline void work(int i, int j, vector<int> &vec) {
  int x = -1, y = -1;
  for (int k = (0); k < (vec.size()); ++k) {
    if (vec[k] == i) x = k;
    if (vec[k] == j) y = k;
  }
  printf("%d %d\n", x + 1, y + 1);
  vec.erase(find(vec.begin(), vec.end(), i));
  return;
}
inline void solve() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", a + i);
  for (int i = (0); i <= (n); ++i)
    for (int j = (0); j <= (n); ++j)
      for (int S = (0); S <= (1 << n); ++S) f[i][j][S] = 0x3f3f3f3f;
  for (int S = (1); S < (1 << n); ++S)
    for (int i = (0); i < (n); ++i)
      if (S >> i & 1) {
        sum[S] = sum[S ^ (1 << i)] + a[i];
        break;
      }
  f[0][0][(1 << n) - 1] = -0x3f3f3f3f;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (n); ++j)
      for (int S = (0); S < (1 << n); ++S)
        if (f[i][j][S] != 0x3f3f3f3f) {
          if (S >> i & 1) {
            for (int T = S;; (--T) &= S) {
              if (a[i] + sum[T] > f[i][j][S] && !(T >> i & 1)) {
                int nj = j + __builtin_popcount(T);
                int nS = S ^ T ^ (1 << i);
                f[i + 1][nj][nS] = min(f[i + 1][nj][nS], a[i] + sum[T]);
                if (f[i + 1][nj][nS] == a[i] + sum[T]) {
                  g[i + 1][nj][nS] = make_pair(make_pair(i, j), S);
                }
              }
              if (T == 0) break;
            }
          }
          f[i + 1][j][S] = min(f[i + 1][j][S], f[i][j][S]);
          if (f[i + 1][j][S] == f[i][j][S])
            g[i + 1][j][S] = make_pair(make_pair(i, j), S);
        }
  vector<int> vec;
  for (int i = (0); i < (n); ++i) vec.push_back(i);
  for (int j = (0); j <= (n); ++j)
    if (f[n][j][0] != 0x3f3f3f3f) {
      printf("%d\n", j);
      for (int ci = n, cj = j, cS = 0; ci;) {
        int ni = g[ci][cj][cS].first.first, nj = g[ci][cj][cS].first.second,
            nS = g[ci][cj][cS].second;
        for (int k = (0); k < (n); ++k)
          if (((cS ^ nS) >> k & 1) && k != ci - 1) work(k, ci - 1, vec);
        ci = ni, cj = nj, cS = nS;
      }
      return;
    }
  return;
}
int main() {
  for (scanf("%d", &T); T--; solve())
    ;
  return 0;
}
