#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline int chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline int chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline T read(T &f) {
  f = 0;
  int x = 1;
  char c = getchar();
  while (!isdigit(c)) x = c == '-' ? -1 : 1, c = getchar();
  while (isdigit(c)) (f *= 10) += c & 15, c = getchar();
  return f *= x;
}
using int64 = long long;
using uint64 = unsigned long long;
namespace TASK {
const int N = 100000 + 5;
int n, A[N];
int main() {
  read(n);
  for (int i = (1), ___ = (n); i <= ___; ++i) read(A[i]);
  if (A[1] == 1) {
    printf("%d ", n + 1);
    for (int i = (1), ___ = (n); i <= ___; ++i) printf("%d ", i);
    return 0;
  }
  for (int i = (1), ___ = (n - 1); i <= ___; ++i) {
    if (A[i] == 0 && A[i + 1] == 1) {
      for (int j = (1), ___ = (i); j <= ___; ++j) printf("%d ", j);
      printf("%d ", n + 1);
      for (int j = (i + 1), ___ = (n); j <= ___; ++j) printf("%d ", j);
      return 0;
    }
  }
  for (int i = (1), ___ = (n); i <= ___; ++i) printf("%d ", i);
  printf("%d ", n + 1);
  return 0;
}
}  // namespace TASK
int main() {
  static int T;
  read(T);
  while (T--) TASK::main();
  return 0;
}
