#include <bits/stdc++.h>
using namespace std;
const int N = 15;
const int INF = 1E9 + 7;
int dp[N + 1][1 << N][N + 1];
pair<int, int> p[N + 1][1 << N][N + 1];
int n, a[N], sum[1 << N];
void work() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < (1 << n); i++) {
    sum[i] = 0;
    for (int j = 0; j < n; j++)
      if ((1 << j) & i) sum[i] += a[j];
  }
  for (int i = 0; i <= n; i++)
    for (int j = 0; j < (1 << n); j++)
      for (int z = 0; z <= n; z++) dp[i][j][z] = INF;
  dp[0][0][0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << n); j++)
      for (int z = 0; z < n; z++) {
        if (dp[i - 1][j][z] == INF) continue;
        int m = j ^ ((1 << n) - 1);
        for (int k = m; k; k = (k - 1) & m) {
          if (sum[k] <= dp[i - 1][j][z]) continue;
          if ((k >> z) == 0) continue;
          int nz = z + __builtin_ctz(k >> z) + 1;
          if (dp[i][j | k][nz] > sum[k]) {
            dp[i][j | k][nz] = sum[k];
            p[i][j | k][nz] = pair<int, int>(j, z);
          }
        }
      }
  int a = -1, c = -1;
  for (int i = n; i >= 0; i--) {
    for (int z = n; z >= 0; z--)
      if (dp[i][(1 << n) - 1][z] < INF) {
        c = z;
        break;
      }
    if (c != -1) {
      a = i;
      break;
    }
  }
  vector<pair<int, int> > ans;
  int b = (1 << n) - 1;
  for (int i = a; i > 0; i--) {
    int nb = p[i][b][c].first;
    int nc = p[i][b][c].second;
    int m = nb ^ b;
    for (int j = 0; j < n; j++)
      if (m & (1 << j) && j != c - 1) ans.push_back(pair<int, int>(j, c - 1));
    b = nb, c = nc;
  }
  cout << (int)ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) {
    int x = ans[i].first;
    int y = ans[i].second;
    for (int j = 0; j < i; j++)
      if (ans[j].first < ans[i].first) x--;
    for (int j = 0; j < i; j++)
      if (ans[j].first < ans[i].second) y--;
    cout << x + 1 << ' ' << y + 1 << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) work();
}
