#include <bits/stdc++.h>
using namespace std;
long long mex(map<long long, long long> &mp, long long n) {
  for (int i = 0; i < n; i++)
    if (!mp[i]) return i;
  return n;
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long arr[n];
    vector<int> ans;
    map<long long, long long> mp;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      mp[arr[i]]++;
    }
    while (1) {
      long long temp = mex(mp, n);
      int j = 0;
      for (j; j < n; j++)
        if (arr[j] != j) break;
      if (j >= n) break;
      if (temp >= n) {
        mp[arr[j]]--;
        arr[j] = temp;
        mp[temp]++;
        ans.push_back(j + 1);
      } else {
        mp[arr[temp]]--;
        ans.push_back(temp + 1);
        arr[temp] = temp;
        mp[temp]++;
      }
    }
    cout << ans.size() << endl;
    for (auto a : ans) cout << a << " ";
    cout << endl;
  }
}
