#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T;
  cin >> T;
  while (T--) {
    long long n, i;
    cin >> n;
    vector<long long> a(n + 1);
    a[0] = -1;
    for (i = 1; i <= n; i++) {
      cin >> a[i];
    }
    vector<long long> answer;
    long long break_ind = n + 10;
    bool check = false;
    for (i = 1; i <= n; i++) {
      if (a[i] == 1 && !check) {
        answer.push_back(i);
      }
      if (a[i] == 1 && check) {
        break_ind = i;
        break;
      }
      if (a[i] == 0) {
        check = true;
        answer.push_back(i);
      }
    }
    if (check) {
      answer.push_back(n + 1);
    }
    for (i = break_ind; i <= n; i++) {
      answer.push_back(i);
    }
    if (check) {
      for (long long i = 0; i < answer.size(); i++) {
        cout << answer[i] << " ";
      }
      cout << "\n";
      ;
    } else {
      vector<long long> final_ans;
      final_ans.push_back(n + 1);
      for (i = 1; i <= n; i++) {
        final_ans.push_back(i);
      }
      for (long long i = 0; i < final_ans.size(); i++) {
        cout << final_ans[i] << " ";
      }
      cout << "\n";
      ;
    }
  }
  return 0;
}
