#include <bits/stdc++.h>
using namespace std;
long double pie = 3.141592653589793238462643383279;
long long mod = 1e9 + 7;
long long dx[] = {-1, 1, 0, 0};
long long dy[] = {0, 0, 1, -1};
long long fact[2000005];
long long infact[2000005];
long long inv(long long a) {
  long long y = mod - 2;
  long long r = 1;
  while (y != 0) {
    if (y & 1) {
      r *= a;
      r %= mod;
    }
    y /= 2;
    a *= a;
    a %= mod;
  }
  return r;
}
long long po(long long a, long long y) {
  long long r = 1;
  while (y != 0) {
    if (y & 1) {
      r *= a;
      r %= mod;
    }
    y /= 2;
    a *= a;
    a %= mod;
  }
  return r;
}
void facto() {
  fact[0] = 1;
  for (long long i = 1; i < (long long)2000005; ++i) {
    fact[i] = i * fact[i - 1];
    fact[i] %= mod;
  }
  for (long long i = 0; i < (long long)2000005; ++i) infact[i] = inv(fact[i]);
}
long long nck(long long n, long long k) {
  if (k < 0 || k > n) return 0;
  long long ret = fact[n];
  ret *= infact[k];
  ret %= mod;
  ret *= infact[n - k];
  ret %= mod;
  return ret;
}
long long n, m;
vector<long long> adj[1000005];
bool vis[1000005];
bool vis2[1000005];
long long ans[1000005];
bool poss = 1;
long long dfs(long long c, long long p) {
  bool lp = 1;
  long long leaf = 0;
  for (auto it : adj[c]) {
    if (it != p) {
      lp = 0;
      leaf += dfs(it, c);
    }
  }
  if (lp)
    return 1;
  else {
    if (leaf < 3) poss = 0;
    return 0;
  }
}
void dfs2(long long s, long long val) {
  if (vis2[s]) return;
  vis2[s] = 1;
  ans[s] = val;
  for (auto it : adj[s]) dfs2(it, val);
}
long long rev(long long a) {
  long long r = 0;
  while (a != 0) {
    r += a % 10;
    r *= 10;
    a /= 10;
  }
  return r / 10;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tt = 1;
  cin >> tt;
  while (tt--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < (long long)n; ++i) cin >> a[i];
    vector<long long> ret;
    vector<long long> un;
    for (long long i = 0; i < (long long)n; ++i)
      if (a[i] != i) {
        un.push_back(i);
      }
    long long xp = un.size();
    while (xp > 0) {
      long long cp[n];
      for (long long i = 0; i < (long long)n; ++i) cp[i] = a[i];
      sort(cp, cp + n);
      long long expec = 0;
      for (long long i = 0; i < (long long)n; ++i) {
        if (i != 0 && cp[i] == cp[i - 1]) continue;
        if (cp[i] != expec) break;
        ++expec;
      }
      if (expec == n) {
        ret.push_back(un[xp - 1]);
        a[un[xp - 1]] = n;
      } else {
        ret.push_back(expec);
        a[expec] = expec;
        vector<long long> tmp;
        bool fg = 0;
        for (auto it : un)
          if (it == expec) {
            fg = 1;
            continue;
          } else
            tmp.push_back(it);
        assert(fg == 1);
        un = tmp;
        --xp;
      }
    }
    cout << ret.size() << "\n";
    for (auto it : ret) cout << it + 1 << " ";
    cout << "\n";
  }
  return 0;
}
