#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
const int mod = 998244353;
const double Pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int G = 3, Gi = 332748118;
long long qpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int n, m;
vector<int> res;
int vis[N];
int a[N];
int b[N];
int MEX() {
  for (int i = 0; i <= n; ++i) {
    if (!vis[i]) return i;
  }
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    res.clear();
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
      vis[a[i]]++;
    }
    int l = 1;
    while (l <= n) {
      int tp = MEX();
      if (tp == 0) {
        while (l <= n && a[l] == l) l++;
        if (l > n) break;
        res.push_back(l);
        vis[a[l]]--;
        vis[0] = 1;
        a[l] = 0;
        continue;
      }
      vis[a[tp]]--;
      vis[tp]++;
      a[tp] = tp;
      res.push_back(tp);
    }
    int tt = res.size();
    printf("%d\n", tt);
    for (int i = 0; i < tt; ++i) {
      if (i == tt - 1)
        printf("%d\n", res[i]);
      else
        printf("%d ", res[i]);
    }
  }
  return 0;
}
