#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const long long infll = (long long)1.01e18;
const long double eps = 1e-9;
const long double pi = acos((long double)-1);
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
void precalc() {}
const int maxn = 1005;
int n;
int a[maxn];
bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}
vector<int> ans;
int used[maxn];
int curu;
int getMex() {
  curu++;
  for (int i = 0; i < n; i++) {
    used[a[i]] = curu;
  }
  int mex = 0;
  while (used[mex] == curu) {
    mex++;
  }
  return mex;
}
void doOp(int pos) {
  int mex = getMex();
  a[pos] = mex;
  ans.push_back(pos);
}
void solve() {
  ans.clear();
  while (true) {
    int mex = getMex();
    if (mex >= n) {
      break;
    }
    doOp(mex);
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == i) {
      continue;
    }
    int x = a[i];
    doOp(i);
    while (x < n) {
      int nx = a[x];
      doOp(x);
      x = nx;
    }
  }
  for (int i = 0; i < n; i++) {
    assert(a[i] == i);
  }
  assert(((int)(ans).size()) <= 2 * n);
  printf("%d\n", ((int)(ans).size()));
  for (int i = 0; i < ((int)(ans).size()); i++) {
    printf("%d ", ans[i] + 1);
  }
  printf("\n");
}
int main() {
  precalc();
  int t;
  scanf("%d", &t);
  while (read()) {
    solve();
  }
  return 0;
}
