#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long f[n + 1];
  for (long long i = 0; i < n + 1; i++) {
    f[i] = 0;
  }
  long long a[n];
  for (long long i = 0; i < n; i++) {
    long long t;
    cin >> t;
    a[i] = t;
    f[t]++;
  }
  vector<long long> ans;
  for (long long i = 0; i < 2 * n; i++) {
    long long mx = 0;
    while (f[mx] > 0) mx++;
    if (mx < n) {
      ans.push_back(mx);
      f[a[mx]]--;
      a[mx] = mx;
      f[a[mx]]++;
    } else {
      long long pt = -1;
      for (long long i = 0; i < n; i++) {
        if (a[i] != i) pt = i;
      }
      if (pt != -1) {
        ans.push_back(pt);
        f[a[pt]]--;
        a[pt] = mx;
        f[a[pt]]++;
      } else
        break;
    }
  }
  cout << ans.size() << "\n";
  for (auto it : ans) cout << it + 1 << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long ntc = 1;
  cin >> ntc;
  for (long long tc = 1; tc < ntc + 1; tc++) {
    solve();
  }
}
