#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int inf = 2e9 + 1;
const int maxn = 1e4 + 5;
int a[maxn];
int c[maxn];
int cnt[maxn << 1];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a[i]);
      cnt[a[i]] += 1;
    }
    int k = 0;
    while (true) {
      int pos = 0;
      while (pos < n - 1 && a[pos] <= a[pos + 1]) pos += 1;
      if (pos + 1 == n) break;
      pos = 0;
      while (cnt[pos]) pos += 1;
      if (pos >= n) {
        for (int i = 0; i < n; ++i) {
          if (a[i] != i) {
            cnt[a[i]] -= 1, cnt[pos] += 1;
            a[i] = pos, c[k++] = i;
            break;
          }
        }
      } else {
        cnt[a[pos]] -= 1, cnt[pos] += 1;
        a[pos] = pos, c[k++] = pos;
      }
    }
    printf("%d\n", k);
    if (k == 0) puts("");
    for (int i = 0; i < k; ++i)
      printf("%d%c", c[i] + 1, i + 1 == k ? '\n' : ' ');
  }
  return 0;
}
