#include <bits/stdc++.h>
using namespace std;
void boost() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), p(n + 1, 0), steps;
  for (int i = 0; i < (n); ++i) cin >> a[i];
  for (int i = 0; i < (n); ++i) p[a[i]]++;
  int u, d = 0;
  for (int i = 0; i < (n); ++i) {
    u = -1;
    for (int m = 0; m < (n); ++m) {
      if (a[m] != m) u = m;
      if (p[m] == 0) {
        p[m]++;
        p[a[m]]--;
        a[m] = m;
        steps.push_back(m);
        break;
      }
      if (m == n - 1) {
        if (u == -1) {
          d = 1;
          break;
        }
        p[a[u]]--;
        p[n]++;
        a[u] = n;
        steps.push_back(u);
        m = -1;
      }
    }
    if (d == 1) break;
  }
  cout << steps.size() << "\n";
  for (auto x : steps) cout << x + 1 << " ";
  cout << "\n";
}
int main() {
  boost();
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
}
