#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    vector<long long> count(n + 1, 0);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      count[a[i]]++;
    }
    int mex = -1;
    vector<long long> res;
    for (int i = 0; i < n; i++) {
      if (mex == n)
        for (int j = 0; j <= n; j++) {
          if (count[j] == 0) {
            mex = j;
            break;
          }
        }
    }
    vector<bool> visited(n + 1, false);
    int curr = 0, T = 0;
    while (curr < n && T < n) {
      for (int j = 0; j <= n; j++) {
        if (count[j] == 0) {
          mex = j;
          break;
        }
      }
      if (mex == n) {
        while (visited[curr]) {
          curr++;
          if (curr == n) break;
        }
        if (curr == n) break;
        count[a[curr]]--;
        count[mex]++;
        a[curr] = mex;
        res.push_back(curr + 1);
      } else {
        count[a[mex]]--;
        count[mex]++;
        visited[mex] = true;
        res.push_back(mex + 1);
        T++;
      }
    }
    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) cout << res[i] << " ";
    cout << endl;
  }
  return 0;
}
