#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> ans;
  set<int> s;
  bool segunda_parte = false;
  vector<int> pos(n + 1, -1);
  while (true) {
    bool f = true;
    for (int i = 1; i < n; i++)
      if (a[i] < a[i - 1]) f = false;
    if (f) break;
    s.clear();
    for (int x : a) s.insert(x);
    int mex = 0;
    while (true) {
      if (s.find(mex) == s.end()) break;
      mex++;
    }
    if (mex == n) segunda_parte = true;
    if (!segunda_parte) {
      ans.push_back(mex);
      a[mex] = mex;
    } else {
      for (int i = 0; i <= n; i++) pos[i] = -1;
      for (int i = 0; i < n; i++) pos[a[i]] = i;
      int poner = -1;
      for (int i = 0; i < n; i++) {
        if (pos[i] != i) {
          poner = i;
          break;
        }
      }
      if (poner == -1) break;
      if (mex == poner) {
        a[mex] = mex;
        ans.push_back(mex);
      } else {
        assert(pos[poner] >= 0);
        a[pos[poner]] = mex;
        ans.push_back(pos[poner]);
        a[poner] = poner;
        ans.push_back(poner);
      }
    }
  }
  cout << ans.size() << '\n';
  for (auto e : ans) cout << e + 1 << " ";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
