#include <bits/stdc++.h>
using namespace std;
using big = long long;
const int N = 1200;
int a[N];
bool vis[N];
int cnt[N];
int n;
int mex() {
  for (int i = 0; i <= n; ++i) {
    if (!cnt[i]) {
      return i;
    }
  }
  return -1;
}
void put(int x, int y, vector<int> &ops) {
  --cnt[a[x]];
  a[x] = y;
  ++cnt[y];
  ops.push_back(x + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  int cas;
  cin >> cas;
  while (cas--) {
    cin >> n;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      ++cnt[a[i]];
    }
    int unset = 0;
    for (int i = 0; i < n; ++i) {
      unset += a[i] != i;
    }
    vector<int> ops;
    while (unset) {
      int x = mex();
      if (x == n) {
        for (int i = 0; i < n; ++i) {
          if (i != a[i]) {
            put(i, x, ops);
            break;
          }
        }
      } else {
        put(x, x, ops);
        --unset;
      }
    }
    cout << ops.size() << '\n';
    for (int v : ops) {
      cout << v << ' ';
    }
    cout << '\n';
    assert(ops.size() <= 2 * n);
  }
  return 0;
}
