#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    map<int, int> m;
    for (int i = 0; i < n; i++) {
      if (m.find(a[i]) == m.end()) {
        m[a[i]] = 1;
      } else {
        m[a[i]]++;
      }
    }
    int k = 0;
    vector<int> v;
    set<int> s;
    for (int i = 0; i < n + 1; i++) {
      s.insert(i);
    }
    for (int i = 0; i < n; i++) {
      s.erase(a[i]);
    }
    int q = 0;
    while (true) {
      int c = n - 1;
      for (int i = 0; i < n; i++) {
        if (a[i] != i) {
          c = i;
          goto process;
        }
      }
      break;
    process:;
      k++;
      int mex = *(s.begin());
      if (mex >= n) {
        v.push_back(c + 1);
        int temp = a[c];
        a[c] = mex;
        m[temp]--;
        if (m[temp] <= 0) {
          m.erase(temp);
          s.insert(temp);
        }
        s.erase(mex);
        q = c;
      } else {
        v.push_back(mex + 1);
        int temp = a[mex];
        a[mex] = mex;
        m[temp]--;
        if (m[temp] <= 0) {
          m.erase(temp);
          s.insert(temp);
        }
        s.erase(mex);
      }
    }
    cout << k << endl;
    for (auto i : v) {
      cout << i << " ";
    }
    cout << endl;
  }
  return 0;
}
