#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int a[N];
map<int, int> mp;
int mex() {
  for (int i = 0;; ++i) {
    if (mp.find(i) == mp.end()) {
      return i;
    }
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    bool flag = true;
    for (int i = 0; i < n - 1; ++i) {
      if (a[i] > a[i + 1]) {
        flag = false;
        break;
      }
    }
    if (!flag) {
      vector<int> res;
      for (int i = 0; i < n; ++i) {
        ++mp[a[i]];
      }
      while (1) {
        bool flag = true;
        for (int i = 0; i < n - 1; ++i) {
          if (a[i] > a[i + 1]) {
            flag = false;
            break;
          }
        }
        if (flag) {
          break;
        }
        int t = mex();
        int old;
        if (t == n) {
          int i;
          for (i = 0; i < n; ++i) {
            if (a[i] != i) {
              old = a[i];
              a[i] = t;
              res.push_back(i + 1);
              break;
            }
          }
          --mp[old];
          if (mp[old] == 0) {
            mp.erase(old);
          }
          ++mp[a[i]];
        } else if (t < n) {
          int old = a[t];
          a[t] = t;
          res.push_back(t + 1);
          --mp[old];
          if (mp[old] == 0) {
            mp.erase(old);
          }
          ++mp[a[t]];
        }
      }
      printf("%d\n", res.size());
      for (int i = 0; i < res.size(); ++i) printf("%d ", res[i]);
    } else {
      puts("0");
    }
    puts("");
    mp.clear();
  }
  return 0;
}
