#include <bits/stdc++.h>
using namespace std;
int read() {
  char x = getchar();
  int u = 0, fg = 0;
  while (!isdigit(x)) {
    if (x == '-') fg = 1;
    x = getchar();
  }
  while (isdigit(x)) {
    u = (u << 3) + (u << 1) + (x ^ 48);
    x = getchar();
  }
  return fg ? -u : u;
}
const int maxx = 1e4 + 5;
int n, a[maxx], k[maxx], mex, cnt, pos;
int num[maxx];
bool pd() {
  for (register int i = (2); i <= (n); ++i)
    if (a[i] < a[i - 1]) return 0;
  return 1;
}
int main() {
  int T = read();
  while (T--) {
    n = read();
    cnt = 0;
    for (register int i = (0); i <= (n); ++i) num[i] = 0;
    for (register int i = (1); i <= (n); ++i) {
      a[i] = read();
      num[a[i]]++;
    }
    while (1) {
      if (pd() == 1) break;
      for (register int i = (0); i <= (n); ++i)
        if (!num[i]) {
          mex = i;
          break;
        }
      if (mex == n) {
        for (register int i = (1); i <= (n); ++i)
          if (a[i] != i - 1) {
            pos = i;
            break;
          }
        num[a[pos]]--;
        num[n]++;
        a[pos] = mex;
        k[++cnt] = pos;
        continue;
      }
      num[a[mex + 1]]--;
      a[mex + 1] = mex;
      num[mex]++;
      k[++cnt] = mex + 1;
    }
    printf("%d\n", cnt);
    for (register int i = (1); i <= (cnt); ++i) printf("%d ", k[i]);
    printf("\n");
  }
  return 0;
}
