#include <bits/stdc++.h>
using namespace std;
void init_code() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void call() {
  int n;
  cin >> n;
  vector<int> arr(n + 1);
  for (int i = 1; i <= n; i++) cin >> arr[i];
  if (arr[n] == 0) {
    for (int i = 1; i <= n + 1; i++) cout << i << " ";
    return;
  } else {
    int cnt1 = 0;
    for (auto& x : arr) cnt1 += x;
    if (cnt1 == n) {
      cout << n + 1 << " ";
      for (int i = 1; i <= n; i++) cout << i << " ";
      return;
    }
    int i = 1;
    for (; i <= n; i++) {
      cout << i << " ";
      if (arr[i] == 0 && arr[i + 1] == 1) {
        cout << n + 1 << " ";
        for (i = i + 1; i <= n; i++) cout << i << " ";
        return;
      }
    }
  }
}
int main() {
  init_code();
  int t;
  cin >> t;
  while (t--) {
    call();
    cout << endl;
  }
  return 0;
}
