#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)998244353;
long long binPow(long long a, long long b) {
  if (b == 0) return 1;
  long long ans = binPow(a, b / 2);
  ans = ans * ans % MOD;
  if (b % 2) {
    ans = ans * a % MOD;
  }
  return ans;
}
int getMex(vector<int> a) {
  sort((a).begin(), (a).end());
  if (a[0] != 0) return 0;
  for (int i = 1; i < a.size(); ++i) {
    if (a[i] != a[i - 1] && a[i - 1] + 1 != a[i]) {
      return a[i - 1] + 1;
    }
  }
  return a.back() + 1;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> op;
  int currentMex;
  for (int i = 0; i < n; ++i) {
    while ((currentMex = getMex(a)) != n) {
      op.push_back(currentMex);
      a[currentMex] = currentMex;
    }
    if (a[i] == i) continue;
    for (int j = i + 1; j < n; ++j) {
      if (a[j] == i) {
        op.push_back(j);
        a[j] = n;
        op.push_back(i);
        a[i] = i;
        break;
      }
    }
  }
  cout << op.size() << "\n";
  for (int i : op) cout << i + 1 << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  srand(time(0));
  int tests;
  cin >> tests;
  while (tests--) solve();
}
