#include <bits/stdc++.h>
using namespace std;
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
  return 0;
}
int mex(const vector<int> &v) {
  set<int> st;
  for (int i = 0; i < int(v.size()); i++) {
    st.insert(v[i]);
  }
  int ret = 0;
  while (st.find(ret) != st.end()) {
    ret++;
  }
  return ret;
}
bool isSorted(const vector<int> &v) {
  const int n = v.size();
  for (int i = 0; i < n - 1; i++) {
    if (v[i] > v[i + 1]) return false;
  }
  return true;
}
void calc(vector<int> &a, vector<int> &res) {
  while (true) {
    int p = mex(a);
    if (isSorted(a)) break;
    a[max(p - 1, 0)] = p;
    res.push_back(p);
  }
}
void Main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<int> res;
    while (true) {
      if (isSorted(a)) break;
      int p = mex(a);
      if (p == 0) {
        for (int i = 0; i < n; i++) {
          if (a[i] != i + 1) {
            a[i] = 0;
            res.push_back(i + 1);
            break;
          }
        }
        continue;
      }
      a[p - 1] = p;
      res.push_back(p);
    }
    cout << res.size() << '\n';
    for (int i = 0; i < int(res.size()); i++) {
      cout << res[i] << " \n"[i + 1 == int(res.size())];
    }
  }
}
