#include <bits/stdc++.h>
using namespace std;
void solve(void) {
  int n;
  cin >> n;
  vector<int> a(n), cnt(n + 5);
  for (auto& it : a) cin >> it;
  auto mex = [&](void) {
    int res = 0;
    for (int j = 0; j < n; j++) {
      ++cnt[a[j]];
      while (cnt[res]) ++res;
    }
    for (int j = 0; j < n; j++) {
      cnt[a[j]] = 0;
    }
    return res;
  };
  vector<int> res;
  auto can = [&](void) {
    for (int i = 1; i < n; ++i) {
      if (a[i - 1] > a[i]) return true;
    }
    return false;
  };
  while (can()) {
    int m = mex();
    a[min(m, n - 1)] = m;
    res.emplace_back(min(m, n - 1));
    if (m == n) --n;
  }
  cout << res.size() << '\n';
  for (auto& it : res) cout << it + 1 << ' ';
  cout << '\n';
}
signed main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    solve();
  }
}
