#include <bits/stdc++.h>
std::mt19937_64 rng(
    std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
long long mex[10005];
vector<long long> v;
long long y;
long long n;
long long get_mex() {
  y++;
  for (long long i = 0; i < v.size(); i++) mex[v[i]] = y;
  for (long long i = 0; i <= n; i++)
    if (mex[i] != y) return i;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  y = 0;
  cin >> t;
  while (t--) {
    cin >> n;
    v.clear();
    long long x;
    long long bb[n + 5][n + 5];
    memset(bb, 0, sizeof(bb));
    for (long long i = 0; i < n; i++) {
      cin >> x;
      v.push_back(x);
      bb[x][i] = 1;
    }
    vector<long long> temp;
    vector<long long> ans;
    long long w;
    for (long long i = 0; i < n; i++) {
      while (v[i] != i) {
        x = get_mex();
        if (x == n) {
          v[i] = n;
          ans.push_back(i);
        } else {
          v[x] = x;
          ans.push_back(x);
        }
        if (x == i) break;
      }
    }
    cout << ans.size() << '\n';
    for (long long i = 0; i < ans.size(); i++) cout << ans[i] + 1 << " ";
    cout << '\n';
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
