#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e3 + 10;
const int maxm = 5e5 + 10;
const long long INF = 1e18;
long long powmod(long long x, long long y) {
  long long t;
  for (t = 1; y; y >>= 1, x = x * x % mod)
    if (y & 1) t = t * x % mod;
  return t;
}
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int t, n, a[maxn], vis[maxn];
int mex() {
  int idx = 0;
  memset((vis), (0), sizeof(vis));
  for (int(i) = (0); (i) < (n); (i)++) vis[a[i]] = 1;
  while (vis[idx]) idx++;
  return idx;
}
vector<int> ret;
int judge() {
  for (int(i) = (0); (i) < (n); (i)++)
    if (a[i] ^ i) return i + 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    ret.clear();
    cin >> n;
    for (int(i) = (0); (i) < (n); (i)++) cin >> a[i];
    int Mex = mex();
    while (Mex ^ n) {
      a[Mex] = Mex;
      ret.push_back(Mex);
      Mex = mex();
    }
    int tmp;
    while (tmp = judge()) {
      a[tmp - 1] = mex();
      ret.push_back(tmp - 1);
      Mex = mex();
      while (Mex != n) {
        a[Mex] = Mex;
        ret.push_back(Mex);
        Mex = mex();
      }
    }
    cout << ret.size() << "\n";
    for (auto v : ret) cout << v + 1 << " ";
    cout << "\n";
  }
  return 0;
}
