#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
const long long INFLONG = (long long)1e18 + 7;
const double EPS = 1e-9;
template <typename T>
T sqr(T a) {
  return a * a;
}
int mex(vector<int>& a) {
  int n = a.size();
  vector<char> was(n + 1, 0);
  for (int i = 0; i < n; i++) {
    was[a[i]] = 1;
  }
  for (int i = 0; i <= n; i++) {
    if (!was[i]) {
      return i;
    }
  }
  return n + 1;
}
void solve() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  vector<int> ind(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  vector<int> ans;
  while (1) {
    int res = mex(a);
    if (res >= n) {
      break;
    }
    ans.push_back(res + 1);
    a[res] = res;
  }
  char ok = 1;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] > a[i]) {
      ok = 0;
      break;
    }
  }
  if (!ok) {
    vector<int> ind(n);
    for (int i = 0; i < n; i++) {
      ind[a[i]] = i;
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == i) {
        continue;
      }
      int res = mex(a);
      if (res == i) {
        if (a[i] < n) {
          ind[a[i]] = -1;
        }
        a[i] = i;
        ind[i] = i;
        ans.push_back(i + 1);
        continue;
      }
      ans.push_back(ind[i] + 1);
      a[ind[i]] = res;
      if (a[i] < n) {
        ind[a[i]] = -1;
      }
      if (res < n) {
        ind[res] = ind[i];
      }
      res = mex(a);
      ans.push_back(i + 1);
      a[i] = res;
      ind[i] = i;
    }
  }
  int m = ans.size();
  printf("%d\n", m);
  for (int i = 0; i < m; i++) {
    printf("%d%c", ans[i], " \n"[i == m - 1]);
  }
}
int main() {
  srand(time(0));
  int T = 1;
  scanf("%d", &T);
  while (T--) {
    solve();
  }
  return 0;
}
