#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 10;
const int maxm = 4e5 + 10;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double eps = 1e-5;
const double pi = acos(-1.0);
int t;
int n, a[maxn];
int cnt[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> res;
    for (int i = 0; i <= n; i++) cnt[i] = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      cnt[a[i]]++;
    }
    int now;
    while (1) {
      now = 0;
      bool flag = false;
      for (int i = 1; i < n; i++)
        if (a[i] < a[i - 1]) flag = true;
      if (flag == false) break;
      for (int i = 0; i < n; i++) {
        if (cnt[i])
          now = i + 1;
        else
          break;
      }
      if (now == n) {
        int index = 0, minnum = maxn;
        for (int i = 0; i < n; i++)
          if (a[i] != i) {
            if (a[i] < minnum) {
              index = i;
              minnum = a[i];
            }
          }
        int p = a[index];
        cnt[p]--;
        cnt[now]++;
        a[index] = now;
        res.push_back(index);
        continue;
      }
      int p = a[now];
      cnt[p]--;
      cnt[now]++;
      a[now] = now;
      res.push_back(now);
    }
    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) cout << res[i] + 1 << " ";
    cout << endl;
  }
  return ~~(0 - 0);
}
