#include <bits/stdc++.h>
using namespace std;
vector<long long> sieve;
void Sieve(int N) {
  const long long maxn = N;
  sieve.resize(maxn);
  for (long long(i) = 0; (i) < (maxn); ++(i)) sieve[i] = i;
  sieve[1] = -1;
  sieve[0] = -1;
  for (long long(i) = 2; (i) <= (maxn); (i) += (1))
    if (i == sieve[i])
      for (long long j = 2 * i; j < maxn; j += i)
        if (sieve[j] == j) sieve[j] = i;
}
long long extended_GCD(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = extended_GCD(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
long long power(long long a, long long b, long long m = 1000000007) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long modinv(long long a, long long mod = 1000000007) {
  long long x, y;
  extended_GCD(a, mod, x, y);
  if (x < 0) x += mod;
  return x;
}
long long a[3000];
long long n;
long long mex() {
  map<long long, long long> ma;
  vector<long long> v;
  for (int i = 0; i < n; ++i) {
    ma[a[i]]++;
    if (ma[a[i]] == 1) v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    if (i != v[i]) return i;
  }
  return v.size();
}
bool is_sorted() {
  for (int i = 1; i < n; i++)
    if (a[i] < a[i - 1]) return 0;
  return 1;
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<long long> v;
  long long c = n - 1;
  long long f = 0;
  while (!is_sorted()) {
    long long x = mex();
    if (x == c + 1)
      a[c] = x, v.push_back(c + 1), c--;
    else
      a[x] = x, v.push_back(x + 1);
  }
  cout << v.size() << "\n";
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] << " ";
  }
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
