#include <bits/stdc++.h>
using namespace std;
int t, n, a[1005], c[1005], stk[1005], top, ans[2005];
int Mex() {
  for (int i = (1), _ = (n + 1); i <= _; i++) c[i] = 0;
  for (int i = (1), _ = (n); i <= _; i++) c[a[i]] = 1;
  int cur = 0;
  while (c[cur + 1]) cur++;
  return cur + 1;
}
int main() {
  for (cin >> t; t--;) {
    cin >> n;
    for (int i = (1), _ = (n); i <= _; i++) cin >> a[i], a[i]++;
    top = 0;
    for (int i = (1), _ = (n); i <= _; i++)
      if (a[i] != i) stk[++top] = i;
    ans[0] = 0;
    while (top) {
      int tmp = Mex();
      if (tmp == n + 1) {
        ans[++ans[0]] = stk[top];
        a[stk[top]] = tmp;
        tmp = Mex();
      }
      ans[++ans[0]] = tmp;
      a[tmp] = tmp;
      while (top && a[stk[top]] == stk[top]) stk[top--] = 0;
    }
    printf("%d\n", ans[0]);
    for (int i = (1), _ = (ans[0]); i <= _; i++) printf("%d ", ans[i]);
    puts("");
  }
  return 0;
}
