#include <bits/stdc++.h>
using namespace std;
void Solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  int mex = 0;
  int f = 1;
  vector<int> ans;
  while (f) {
    while (mp[mex]) mex++;
    if (mex >= n) {
      for (int i = 0; i < n; i++)
        if (a[i] != i) {
          ans.push_back(i + 1);
          mp[a[i]]--;
          a[i] = mex;
          mp[mex]++;
          break;
        }
    } else
      mp[a[mex]]--, a[mex] = mex, mp[mex]++, ans.push_back(mex + 1);
    f = 0, mex = 0;
    for (int i = 0; i < n - 1; i++)
      if (a[i] > a[i + 1]) f = 1;
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    Solve();
  }
  return 0;
}
