#include <bits/stdc++.h>
using namespace std;
const long long N = 1000000007;
void solve() {
  int n;
  cin >> n;
  int a[n];
  vector<int> b(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++b[a[i]];
  }
  set<int> mx;
  for (int i = 0; i <= n; ++i) {
    if (b[i] == 0) {
      mx.insert(i);
    }
  }
  vector<int> op;
  while (*mx.begin() != n) {
    int e = *mx.begin();
    mx.erase(*mx.begin());
    ++b[e];
    op.emplace_back(e + 1);
    --b[a[e]];
    if (b[a[e]] == 0) mx.insert(a[e]);
    a[e] = e;
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == i) continue;
    for (int j = i + 1; j < n; ++j) {
      if (a[j] == i) {
        op.emplace_back(j + 1);
        a[j] = *mx.begin();
        mx.erase(mx.begin());
        ++b[a[j]];
        --b[i];
        if (b[i] == 0) mx.insert(i);
      }
    }
    op.emplace_back(i + 1);
    --b[a[i]];
    if (b[a[i]] == 0) mx.insert(a[i]);
    a[i] = *mx.begin();
    mx.erase(mx.begin());
    ++b[a[i]];
  }
  cout << op.size() << endl;
  for (int i = 0; i < op.size(); ++i) cout << op[i] << " ";
  cout << endl;
}
int main() {
  int tt = 1;
  cin >> tt;
  while (tt--) {
    solve();
  }
  return 0;
}
