#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e9;
const long long N = 1000 + 5;
long long ar[N], done[N], cnt[N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    memset(done, 0, sizeof(done));
    memset(cnt, 0, sizeof(cnt));
    long long n;
    cin >> n;
    for (long long i = 0; i < n; i++) {
      cin >> ar[i];
      cnt[ar[i]]++;
    }
    vector<long long> ans;
    for (long long i = 0; i < n; i++) {
      long long mex = 0;
      while (cnt[mex]) mex++;
      long long ind = 0;
      while (done[ind]) ind++;
      if (mex < n) {
        cnt[ar[mex]]--;
        ar[mex] = mex;
        done[mex] = 1;
        cnt[ar[mex]]++;
        ans.push_back(mex + 1);
      } else {
        long long need = 0;
        for (long long j = 0; j < n; j++)
          if (ar[j] == ind) need = j;
        done[ind] = 1;
        if (ind != need) {
          cnt[ar[need]]--;
          cnt[ar[ind]]--;
          ar[need] = n;
          ar[ind] = ind;
          cnt[ar[need]]++;
          cnt[ar[ind]]++;
          ans.push_back(need + 1);
          ans.push_back(ind + 1);
        }
      }
    }
    cout << ans.size() << '\n';
    for (auto &inx : ans) cout << inx << " ";
    cout << '\n';
  }
}
