#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
const int N = 1001;
int n, T, a[N], cnt[N];
bool use[N];
int findmex() {
  for (int i = (0); i <= (n); ++i)
    if (!cnt[i]) return i;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = (1); i <= (n); ++i) cin >> a[i];
    fill(use, use + 1 + n, 0);
    fill(cnt, cnt + 1 + n, 0);
    vector<int> ans;
    for (int i = (1); i <= (n); ++i) cnt[a[i]]++;
    for (int i = (1); i <= (n); ++i) {
      int mex = findmex();
      if (mex == n) {
        for (int j = (1); j <= (n); ++j)
          if (!use[j]) {
            ans.emplace_back(j);
            cnt[a[j]]--;
            cnt[n]++;
            a[j] = n;
            break;
          }
        mex = findmex();
      }
      ans.emplace_back(mex + 1);
      use[mex + 1] = 1;
      cnt[a[mex + 1]]--;
      a[mex + 1] = mex;
      cnt[mex]++;
    }
    cout << ((int)(ans).size()) << '\n';
    for (int v : ans) cout << v << ' ';
    cout << '\n';
  }
  return 0;
}
