#include <bits/stdc++.h>
using namespace std;
long long dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
long long dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const long long maxn = 1e5;
const long long OO = 1e18;
const long long mod = 1e9 + 7;
const long double PI = acos(-1);
void maxself(long long &a, long long b) { a = max(a, b); }
void minself(long long &a, long long b) { a = min(a, b); }
vector<vector<long long> > g(maxn);
long long n, a[1001];
bool f() {
  for (long long i = 0; i < n - 1; i++)
    if (a[i] > a[i + 1]) return 1;
  return 0;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long mex = -1;
    long long mk[n + 1];
    for (long long i = 0; i <= n; i++) mk[i] = 0;
    for (long long i = 0; i < n; i++) mk[a[i]]++;
    vector<long long> ans;
    while (f()) {
      for (long long i = 0; i <= n; i++)
        if (mk[i] == 0) {
          mex = i;
          break;
        }
      if (mex == n) {
        for (long long i = 0; i < n; i++) {
          if (a[i] != i) {
            mk[a[i]]--;
            mk[mex]++;
            a[i] = mex;
            ans.push_back(i + 1);
            break;
          }
        }
      } else
        mk[mex]++, mk[a[mex]]--, a[mex] = mex, ans.push_back(mex + 1);
    }
    cout << ans.size() << "\n";
    for (auto x : ans) cout << x << ' ';
    cout << "\n";
  }
  return 0;
}
