#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), ans;
  for (int& x : a) cin >> x;
  auto mex = [&]() {
    unordered_set<int> S;
    for (int x : a) S.insert(x);
    for (int i = 0; i < n; i++) {
      if (!S.count(i)) return i;
    }
    return n;
  };
  for (int i = 0; i < n; i++) {
    int M = mex();
    if (a[i] != i) {
      while (M != i) {
        if (M == n) {
          for (int j = i + 1; j < n && M == n; j++) {
            if (a[j] == i) {
              ans.push_back(j);
              a[j] = M;
              M = mex();
            }
          }
        } else {
          ans.push_back(M);
          a[M] = M;
          M = mex();
        }
      }
      ans.push_back(i);
      a[i] = M;
      M = mex();
    }
  }
  assert(ans.size() <= 2 * n);
  cout << ans.size() << '\n';
  for (int x : ans) cout << x + 1 << ' ';
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
