#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
const int M = 2e3 + 5;
const int INF = 2e9;
const int sz = 15;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);
template <class T>
inline void read(T &x) {
  char c;
  x = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') x = -1;
  T res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0';
  x *= res;
}
int n, m;
char str[N];
int f[N];
int main() {
  int t;
  read(t);
  while (t--) {
    read(n);
    unordered_map<int, int> mm;
    for (int i = 1; i <= n; i++) {
      read(f[i]);
      mm[f[i]]++;
    }
    vector<int> ans;
    while (1) {
      bool flag = 1;
      for (int i = 1; i <= n - 1; i++) {
        if (f[i] > f[i + 1]) {
          flag = 0;
          break;
        }
      }
      if (flag) break;
      int least;
      for (int j = 0; j <= n; j++) {
        if (!mm.count(j) || mm[j] == 0) {
          least = j;
          break;
        }
      }
      if (least == n) {
        int pos;
        for (int i = 1; i <= n; i++) {
          if (f[i] != i - 1) {
            pos = i;
            break;
          }
        }
        mm[f[pos]]--;
        mm[n]++;
        f[pos] = n;
        ans.push_back(pos);
      } else {
        mm[f[least + 1]]--;
        mm[least]++;
        f[least + 1] = least;
        ans.push_back(least + 1);
      }
    }
    cout << ans.size() << endl;
    for (int x : ans) cout << x << ' ';
    cout << endl;
  }
  return 0;
}
