#include <bits/stdc++.h>
using namespace std;
int MEX(int*, int*, int);
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n, *arr;
    vector<int> ans;
    cin >> n;
    arr = new int[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    int t, j = 0;
    while (j < n && arr[j] == j) ++j;
    while (j != n) {
      t = MEX(arr, arr + n, n);
      if (t == n) {
        for (int i = 0; i < n; i++) {
          if (arr[i] == j) {
            ans.push_back(i + 1);
            arr[i] = n;
            break;
          }
        }
      } else {
        ans.push_back(t + 1);
        arr[t] = t;
      }
      while (j < n && arr[j] == j) ++j;
    }
    cout << ans.size() << '\n';
    for (auto& v : ans) cout << v << ' ';
    cout << '\n';
  }
  return 0;
}
int MEX(int* b, int* e, int n) {
  bool* rep = new bool[n + 1]{};
  for (int* pt = b; pt != e; ++pt) {
    rep[*pt] = true;
  }
  for (int i = 0; i <= n; i++) {
    if (!rep[i]) {
      delete[] rep;
      return i;
    }
  }
}
