#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll t;
  cin >> t;
  for (ll i = 0; i < t; i++) {
    ll n;
    cin >> n;
    vector<ll> in(n);
    vector<ll> count(n + 1);
    for (ll i = 0; i < n; i++) {
      cin >> in[i];
      count[in[i]]++;
    }
    vector<ll> ops;
    while (true) {
      ll mex = 0;
      while (count[mex] > 0) mex++;
      if (mex < n) {
        ops.push_back(mex);
        count[in[mex]]--;
        in[mex] = mex;
        count[mex]++;
      } else {
        ll j = 0;
        while (in[j] == j) j++;
        if (j >= n) break;
        ops.push_back(j);
        count[in[j]]--;
        in[j] = mex;
        count[mex]++;
      }
    }
    cout << (ll)(ops).size() << endl;
    for (ll x : ops) {
      cout << x + 1 << " ";
    }
    cout << endl;
  }
}
