#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 50;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
int a[1050];
int b[2050];
map<int, int> p;
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  int n, m, k;
  cin >> t;
  while (t--) {
    cin >> n;
    int q = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      p[a[i]]++;
    }
    int cnt = 0;
    cnt = 0;
    while (1) {
      int flag = 1;
      for (int i = 0; i < n; i++) {
        if (p[i] == 0) {
          b[++cnt] = i + 1;
          p[a[i + 1]]--;
          a[i + 1] = i;
          p[i]++;
          flag = 0;
          break;
        }
      }
      if (flag == 0) continue;
      int f = 1;
      for (int i = 1; i <= n; i++) {
        if (a[i] != i - 1) {
          b[++cnt] = i;
          p[a[i]]--;
          a[i] = n;
          p[n]++;
          f = 0;
          break;
        }
      }
      if (f) break;
    }
    cout << cnt << endl;
    for (int i = 1; i <= cnt; i++) cout << b[i] << " ";
    cout << endl;
    p.clear();
  }
  return 0;
}
