#include <bits/stdc++.h>
using namespace std;
int a[1005], c[1006], x[5006];
int s = 0, i = 0, j;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    memset(c, 0, sizeof(c));
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      c[a[i]]++;
    }
    for (s = 0;;) {
      for (i = 1; i < n && a[i] >= a[i - 1]; i++)
        ;
      if (i >= n) break;
      for (i = 0; c[i]; i++)
        ;
      x[s++] = j = i - (i >= n);
      n -= i >= n;
      c[a[j]]--;
      c[i]++;
      a[j] = i;
    }
    cout << s << endl;
    for (int i = 0; i < s; i++) {
      cout << x[i] + 1 << " ";
    }
    cout << endl;
  }
}
