#include <bits/stdc++.h>
using namespace std;
int f[3000], cha[2000];
int a[3000], b[3000], c[3000];
int main() {
  int i, j, n, m, x;
  memset(f, 0, sizeof(f));
  for (i = 2; i <= 2000; i++)
    if (f[i] == 0)
      for (j = i + i; j <= 2000; j += i) f[j] = 1;
  cha[0] = 0;
  for (i = 2; i <= 2000; i++)
    if (!f[i]) cha[++cha[0]] = i;
  int t;
  scanf("%d", &t);
  int o;
  while (t--) {
    scanf("%d", &n);
    for (i = 1; i <= 2 * n; i++) scanf("%d", &a[i]);
    for (i = 1; i <= cha[0]; i++) {
      memset(b, 0, sizeof(b));
      for (j = 1; j <= 2 * n; j++) b[a[j] % cha[i]]++;
      o = b[0] / 2;
      for (j = 1; j < cha[i]; j++) o += min(b[j], b[cha[i] - j]);
      if (cha[i] % 2 == 0)
        o += b[i / 2] / 2;
      else
        o += min(b[i / 2], b[i - i / 2]);
      if (o >= n - 1) {
        x = 0;
        memset(c, 0, sizeof(c));
        for (j = 1; j <= 2 * n; j++)
          if (c[a[j] % cha[i]]) {
            printf("%d %d\n", c[a[j] % cha[i]], j);
            x++;
            c[a[j] % cha[i]] = 0;
            if (x == n - 1) break;
          } else
            c[a[j] % cha[i]] = j;
        break;
      }
    }
  }
  return 0;
}
