// 00
package main

import (
	"bufio"
	"fmt"
	"os"
)

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		to := map[int]bool{}
		from := map[int]bool{}
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
			if a[i] == 0 {
				to[i] = true
			} else {
				from[i] = true
			}
		}
		ok := false
		div := -1
		for i := 0; i < n-1; i++ {
			if to[i] && from[i+1] {
				ok = true
				div = i + 1
				break
			}
		}
		if a[0] == 1 {
			write(f, n+1, " ")
			for i := 1; i <= n; i++ {
				write(f, i)
				if i == n {
					write(f, "\n")
				} else {
					write(f, " ")
				}
			}
		} else if a[n-1] == 0 {
			for i := 1; i <= n+1; i++ {
				write(f, i)
				if i == n+1 {
					write(f, "\n")
				} else {
					write(f, " ")
				}
			}
		} else if ok {
			for i := 1; i <= n; i++ {
				write(f, i)
				if i == div {
					write(f, " ", n+1)
				}
				if i == n {
					write(f, "\n")
				} else {
					write(f, " ")
				}
			}
		} else {
			write(f, "-1\n")
		}

	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Fscan(in,&n)
		var a [30005]int
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		start :=-1
		for i:=1;i<=n;i++{
			if i==n{
				if a[i]==0&&a[1]==1{
					start = i
				}
			}else{
				if a[i]==0&&a[i+1]==1{
					start=i
				}
			}
		}
		ans := []int{}
		if start !=-1 {
			now := start
			for i:=1;i<now;i++{
				ans = append(ans,i)
			}
			ans = append(ans, now)
			ans = append(ans,n+1)
			for i:=now+1;i<=n;i++ {
				ans = append(ans, i)
			}
		}else if a[1]==1{
			ans = append(ans,n+1)
			for i:=1;i<=n;i++{
				ans = append(ans,i)
			}
		}else if a[n]==0{
			for i:=1;i<=n+1;i++{
				ans = append(ans,i)
			}
		}else if a[1]==0&&n==1{
			ans = append(ans,1)
			ans = append(ans,2)
		}
		if len(ans)==0{
			fmt.Fprintln(out,-1)
		}else{
			for i:=0;i<len(ans);i++{
				fmt.Fprintf(out,"%d ",ans[i])
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {
		var n int
		fmt.Fscan(r, &n)

		a := make([]int, n)
		for i := range a { fmt.Fscan(r, &a[i]) }

		if a[n-1] == 0 {
			for i := 1; i <= n+1; i++ {
				fmt.Fprintf(w, "%d ", i)
			}
			fmt.Fprintln(w, "")
		} else if a[0] == 1 {
			fmt.Fprintf(w, "%d ", n+1)
			for i := 1; i <= n; i++ {
				fmt.Fprintf(w, "%d ", i)
			}
			fmt.Fprintln(w, "")
		} else {
			var x int
			for i := 1; i < n; i++ {
				if a[i] == 1 && a[i-1] == 0 {
					x = i
					break
				}
			}
			if x == 0 {
				fmt.Fprintln(w, -1)
			} else {
				for i := 1; i <= x; i++ {
					fmt.Fprintf(w, "%d ", i)
				}
				fmt.Fprintf(w, "%d ", n+1)
				for i := x+1; i <= n; i++ {
					fmt.Fprintf(w, "%d ", i)
				}
				fmt.Fprintln(w, "")
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	defer wr.Flush()

	t := scanInt()

	for i := 0; i < t; i++ {
		n := scanInt()

		nums := make([]int, n)

		for j := 0; j < n; j++ {
			nums[j] = scanInt()
		}

		if nums[len(nums)-1] == 0 {

			for k := 0; k < n; k++ {
				fmt.Print(k+1, " ")
			}

			fmt.Println(n + 1)

		} else if nums[0] == 1 {

			fmt.Print(n+1, " ")

			for k := 0; k < n-1; k++ {
				fmt.Print(k+1, " ")
			}

			fmt.Println(n)

		} else {
			var kPoint int
			for k := n - 1; k > 0; k-- {
				if nums[k] == 1 && nums[k-1] == 0 {
					kPoint = k
					break
				}
			}

			for k := 0; k < kPoint; k++ {
				fmt.Print(k+1, " ")
			}

			fmt.Print(n+1, " ")

			for k := kPoint; k < n; k++ {
				fmt.Print(k+1, " ")
			}
		}

	}
}

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

func scanInt() int {
	sc.Scan()
	ret, _ := strconv.Atoi(sc.Text())
	return ret
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	defer wr.Flush()
	t := scanInt()
	for i := 0; i < t; i++ {
		s := solve()
		if s == nil {
			fmt.Fprintln(wr, -1)
			continue
		}

		for i, v := range s {
			if i > 0 {
				fmt.Fprint(wr, " ")
			}
			fmt.Fprint(wr, v)
		}
		fmt.Fprint(wr, "\n")
	}
}

func solve() []int {
	n := scanInt()
	a := make([]int, n)
	p, q, r := false, false, false
	qi := -1
	for i := 0; i < n; i++ {
		a[i] = scanInt()
		if i == 0 && a[i] == 1 {
			p = true
		} else if i > 0 && (a[i-1] == 0 && a[i] == 1) {
			qi = i
			q = true
		} else if i == n-1 && a[i] == 0 {
			r = true
		}
	}
	if !p && !q && !r {
		return nil
	}

	ret := make([]int, 0, n+1)
	if p {
		ret = append(ret, n+1)
		for i := 1; i <= n; i++ {
			ret = append(ret, i)
		}
	} else if r {
		for i := 1; i <= n+1; i++ {
			ret = append(ret, i)
		}
	} else if q {
		for i := 1; i <= qi; i++ {
			ret = append(ret, i)
		}
		ret = append(ret, n+1)
		for i := qi + 1; i <= n; i++ {
			ret = append(ret, i)
		}
	}
	return ret
}

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

func scanInt() int {
	sc.Scan()
	ret, _ := strconv.Atoi(sc.Text())
	return ret
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
6
1
1
1
0
3
1 1 1
3
0 1 1
3
0 0 1
4
0 0 1 1
---
2 1
1 2
4 1 2 3
1 4 2 3
1 2 4 3
1 2 5 3 4
=====
2
5
0 0 1 0 1
5
0 1 1 1 1
---
1 2 6 3 4 5
1 6 2 3 4 5
=====
4
2
0 0
2
1 0
2
0 1
2
1 1
---
1 2 3
1 2 3
1 3 2
3 2 1
========
2
15
0 1 1 0 1 0 1 0 0 1 0 1 0 1 1
16
0 1 1 0 1 0 1 0 0 1 0 1 0 1 1 0
=====
1
11
0 0 0 1 0 0 1 1 1 0 1
---
1 2 3 12 4 5 6 7 8 9 10 11
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

	if a[n-1] == 0 {
		for i := 1; i <= n+1; i++ {
			fmt.Fprintf(writer, "%d ", i)
		}
		fmt.Fprintln(writer)
		return
	}

	if a[0] == 1 {
		fmt.Fprintf(writer, "%d ", n+1)
		for i := 1; i <= n; i++ {
			fmt.Fprintf(writer, "%d ", i)
		}
		fmt.Fprintln(writer)
		return
	}

	idx01 := 0

	for i := 0; i < n-1; i++ {
		if a[i] == 0 && a[i+1] == 1 {
			idx01 = i + 1
			break
		}
	}

	for i := 1; i <= idx01; i++ {
		fmt.Fprintf(writer, "%d ", i)
	}

	fmt.Fprintf(writer, "%d ", n+1)

	for i := idx01 + 1; i <= n; i++ {
		fmt.Fprintf(writer, "%d ", i)
	}

	fmt.Fprintln(writer)
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T int

	fmt.Fscanf(r, "%d\n", &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscanf(r, "%d\n", &n)
		arr := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscanf(r, "%d", &arr[i])
		}
		fmt.Fscanf(r, "\n")

		b := -1

		if arr[1] == 1 {
			b = 1
		} else if arr[n] == 0 {
			b = n + 1
		} else {
			for i := 2; i <= n; i++ {
				if arr[i-1] == 0 && arr[i] == 1 {
					b = i
					break
				}
			}
		}

		if b == -1 {
			fmt.Println(-1)
		} else {
			for i := 1; ; i++ {
				if b == i {
					fmt.Print(n+1, " ")
				}
				if i == n+1 {
					break
				}
				fmt.Print(i, " ")
			}
			fmt.Println()
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

/* --- Solution C --- */
func solve(in *In, out *Out) {
	n := in.nextInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		v := in.nextInt()
		a[i] = v
	}

	if a[n-1] == 0 {
		for i := 1; i <= n+1; i++ {
			out.printf("%d ", i)
		}
		out.print("\n")
		return
	}
	if a[0] == 1 {
		out.printf("%d ", n+1)
		for i := 1; i <= n; i++ {
			out.printf("%d ", i)
		}
		out.print("\n")
		return
	}
	for i := 0; i < n-1; i++ {
		if a[i] == 0 && a[i+1] == 1 {
			for j := 1; j <= i+1; j++ {
				out.printf("%d ", j)
			}
			out.printf("%d ", n+1)
			for j := i + 2; j <= n; j++ {
				out.printf("%d ", j)
			}
			out.print("\n")
			return
		}
	}
	out.println(-1)
}

func run(in *In, out *Out) {
	cases(in, out)
	// solve(in, out)
}

func main() {
	in := NewIn()
	out := NewOut()
	defer out.flush()

	run(in, out)
}

func cases(in *In, out *Out) {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve(in, out)
	}
}

/* --- I/O --- */
const BUF_MAX_CAP int = 1024

type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	scn := bufio.NewScanner(os.Stdin)

	buf := make([]byte, BUF_MAX_CAP)
	scn.Buffer(buf, BUF_MAX_CAP)
	scn.Split(bufio.ScanWords)

	return &In{scn}
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

func (in *In) nextByte() byte {
	in.scanner.Scan()
	return in.scanner.Text()[0]
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

func (out *Out) println(a ...interface{}) {
	fmt.Fprintln(out.writer, a...)
}

func (out *Out) printf(format string, a ...interface{}) {
	fmt.Fprintf(out.writer, format, a...)
}

func (out *Out) print(a ...interface{}) {
	fmt.Fprint(out.writer, a...)
}

func (out *Out) flush() {
	out.writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

var _, _, _ = main, rw, do

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	rw(r, w)
}

func rw(r io.Reader, w io.Writer) {
	var t int
	var n int
	var a = make([]int, 1e4+2)
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		fmt.Fscan(r, &n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		w1 := do(n, a[:n])
		if len(w1) == 0 {
			fmt.Fprint(w, -1)
		} else {
			for i, v := range w1 {
				if i > 0 {
					fmt.Fprint(w, " ")
				}
				fmt.Fprint(w, v)
			}
		}
		fmt.Fprintln(w)
	}
}

func arr(a, b int) []int {
	r := make([]int, 0, b-a+1)
	for i := a; i <= b; i++ {
		r = append(r, i)
	}
	return r
}

func do(n int, a []int) []int {
	if a[0] == 1 {
		return append([]int{n + 1}, arr(1, n)...)
	}
	if a[n-1] == 0 {
		return arr(1, n+1)
	}
	for i := 0; i < n-1; i++ {
		if a[i] == 0 && a[i+1] == 1 {
			return append(append(arr(1, i+1), n+1), arr(i+2, n)...)
		}
	}
	return nil
}

package main

import "fmt"

func solve() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	if arr[0] == 1 {
		fmt.Printf("%d ", n+1)
		for i := 1; i <= n; i++ {
			fmt.Printf("%d ", i)
		}
	} else if arr[n-1] == 0 {
		for i := 1; i <= n+1; i++ {
			fmt.Printf("%d ", i)
		}
	} else {
		found := false
		for i := 0; i < n-1 && !found; i++ {
			if arr[i] == 0 && arr[i+1] == 1 {
				found = true
				for j := 1; j <= i+1; j++ {
					fmt.Printf("%d ", j)
				}
				fmt.Printf("%d ", n+1)
				for j := i + 2; j <= n; j++ {
					fmt.Printf("%d ", j)
				}
			}
		}
		if !found {
			fmt.Print(-1)
		}
	}
	fmt.Println()
}

func main() {
	var t int
	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	//"math"
	"os"
)

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)
	defer out.Flush()

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n int
		Fscan(in, &n)

		pos := -1
		for i := 1; i <= n; i++ {
			var num int
			Fscan(in, &num)
			if num == 0 {
				pos = i
			}
		}

		if pos == -1 {
			Fprint(out, n + 1, " ")
			for i := 1; i <= n; i++ {
				Fprint(out, i, " ")
			}
		} else {
			for i := 1; i <= pos; i++ {
				Fprint(out, i, " ")
			}
			Fprint(out, n + 1, " ")
			for i := pos + 1; i <= n; i++ {
				Fprint(out, i, " ")
			}
		}
		Fprintln(out)
	}
}

func main() { run(os.Stdin, os.Stdout) }

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a > b {
		 return a
	}
	return b
}

func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

func (s *Scanner) Word() string {
	s.Scan()
	return s.Text()
}

func (s *Scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *Scanner) Int64() int64 {
	s.Scan()
	n, _ := strconv.ParseInt(s.Text(), 10, 64)
	return n
}

func (s *Scanner) Words(count int) []string {
	words := make([]string, count)
	for i := range words {
		words[i] = s.Word()
	}
	return words
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func cont(l, r int) []int {
	res := make([]int, 0, r-l+1)
	for i := l; i <= r; i += 1 {
		res = append(res, i)
	}
	return res
}

func solve(v []int) []int {
	n := len(v) + 1
	if v[0] == 1 {
		return append([]int{n}, cont(1, n-1)...)
	}
	if v[len(v)-1] == 0 {
		return cont(1, n)
	}

	for i := 1; i < len(v); i += 1 {
		if v[i-1] == 0 && v[i] == 1 {
			return append(cont(1, i), append([]int{n}, cont(i+1, n-1)...)...)
		}
	}

	return []int{}
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	tests := stdin.Int()

	for i := 0; i < tests; i += 1 {
		n := stdin.Int()
		v := stdin.Ints(n)

		if res := solve(v); len(res) == 0 {
			fmt.Println(-1)
		} else {
			for _, x := range res {
				fmt.Print(x, " ")
			}
			fmt.Println()
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ans := make([]int, n+1)
		if a[0] == 1 {
			ans[0] = n + 1
			for i := 1; i <= n; i++ {
				ans[i] = i
			}
		} else if a[n-1] == 0 {
			for i := 1; i <= n; i++ {
				ans[i-1] = i
			}
			ans[n] = n + 1
		} else {
			ans = ans[:0]
			for i := 1; i < n; i++ {
				if a[i-1] == 0 && a[i] == 1 {
					ans = append(ans,i, n+1)
					for j := i + 1; j <= n; j++ {
						ans = append(ans, j)
					}
					goto pr
				}
				ans = append(ans, i)
			}
			Fprintln(out, -1)
			return
		}
	pr:
		for _, v := range ans {
			Fprint(out, v, " ")
		}
		Fprintln(out)
	}

	T := 1
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

func main() { run(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)

		ARR := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &ARR[i])
		}
		if n > 1 {
			if ARR[0] == 1 {
				fmt.Println(n + 1)
				for i := 1; i < n+1; i++ {
					fmt.Println(i)
				}
			} else {
				if ARR[n-1] == 0 {
					for i := 1; i < n+1; i++ {
						fmt.Println(i)
					}
					fmt.Println(n + 1)
				} else {
					turn := 0
					for i := 0; i < n-1; i++ {
						if ARR[i] == 0 && ARR[i+1] == 1 {

							turn = i + 1
							break
						}
					}

					for i := 1; i <= turn; i++ {
						fmt.Println(i)
					}
					fmt.Println(n + 1)
					for i := turn + 1; i < n+1; i++ {
						fmt.Println(i)
					}

				}
			}
		} else {
			if ARR[0] == 0 {
				fmt.Println(1)
				fmt.Println(2)
			} else {
				fmt.Println(2)
				fmt.Println(1)

			}
		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)

		ARR := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &ARR[i])
		}
		if n > 1 {
			if ARR[0] == 1 {
				fmt.Println(n + 1)
				for i := 1; i < n+1; i++ {
					fmt.Println(i)
				}
			} else {
				if ARR[n-1] == 0 {
					for i := 1; i < n+1; i++ {
						fmt.Println(i)
					}
					fmt.Println(n + 1)
				} else {
					q := 0
					turn := 0
					for i := 0; i < n-1; i++ {
						if ARR[i] == 0 && ARR[i+1] == 1 {
							q = 1
							turn = i + 1
							break
						}
					}
					if q == 0 {
						fmt.Println(-1)
					} else {
						for i := 1; i <= turn; i++ {
							fmt.Println(i)
						}
						fmt.Println(n + 1)
						for i := turn + 1; i < n+1; i++ {
							fmt.Println(i)
						}
					}
				}
			}
		} else {
			if ARR[0] == 0 {
				fmt.Println(1)
				fmt.Println(2)
			} else {
				fmt.Println(2)
				fmt.Println(1)

			}
		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
6
1
1
1
0
3
1 1 1
3
0 1 1
3
0 0 1
4
0 0 1 1
---
2 1
1 2
4 3 2 1
1 4 2 3
1 2 4 3
1 2 5 3 4
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

	if a[n-1] == 0 {
		for i := 1; i <= n+1; i++ {
			fmt.Fprintf(writer, "%d ", i)
		}
		fmt.Fprintln(writer)
		return
	}

	if a[0] == 1 {
		for i := n + 1; i >= 1; i-- {
			fmt.Fprintf(writer, "%d ", i)
		}
		fmt.Fprintln(writer)
		return
	}

	idx01 := 0

	for i := 0; i < n-1; i++ {
		if a[i] == 0 && a[i+1] == 1 {
			idx01 = i + 1
			break
		}
	}

	for i := 1; i <= idx01; i++ {
		fmt.Fprintf(writer, "%d ", i)
	}

	fmt.Fprintf(writer, "%d ", n+1)

	for i := idx01 + 1; i <= n; i++ {
		fmt.Fprintf(writer, "%d ", i)
	}

	fmt.Fprintln(writer)
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
6
1
1
1
0
3
1 1 1
3
0 1 1
3
0 0 1
4
0 0 1 1
---
2 1
1 2
4 3 2 1
1 4 2 3
1 2 4 3
1 2 5 3 4
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

	if a[0] == 1 {
		for i := n + 1; i >= 1; i-- {
			fmt.Fprintf(writer, "%d ", i)
		}
		fmt.Fprintln(writer)
		return
	}

	if a[n-1] == 0 {
		for i := 1; i <= n+1; i++ {
			fmt.Fprintf(writer, "%d ", i)
		}
		fmt.Fprintln(writer)
		return
	}

	idx01 := 0

	for i := 0; i < n-1; i++ {
		if a[i] == 0 && a[i+1] == 1 {
			idx01 = i + 1
			break
		}
	}

	for i := 1; i <= idx01; i++ {
		fmt.Fprintf(writer, "%d ", i)
	}

	fmt.Fprintf(writer, "%d ", n+1)

	for i := idx01 + 1; i <= n; i++ {
		fmt.Fprintf(writer, "%d ", i)
	}

	fmt.Fprintln(writer)
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
6
1
1
1
0
3
1 1 1
3
0 1 1
3
0 0 1
4
0 0 1 1
---
2 1
1 2
4 3 2 1
-1
1 2 4 3
1 2 5 3 4
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		a := make([]int, n)

		for i := range a {
			scanf("%d", &a[i])
		}
		scanf("\n")

		if a[n-1] == 0 {
			for i := 1; i <= n+1; i++ {
				fmt.Fprintf(writer, "%d ", i)
			}
			fmt.Fprintln(writer)
		} else if a[0] == 1 {
			for i := n + 1; i >= 1; i-- {
				fmt.Fprintf(writer, "%d ", i)
			}
			fmt.Fprintln(writer)
		} else {
			idx01 := -1

			for i := 0; i < n-1; i++ {
				if a[i] == 0 && a[i+1] == 1 {
					idx01 = i + 1
					break
				}
			}

			if idx01 >= 0 {
				for i := 1; i <= idx01; i++ {
					fmt.Fprintf(writer, "%d ", i)
				}

				fmt.Fprintf(writer, "%d ", n+1)

				for i := idx01 + 1; i <= n; i++ {
					fmt.Fprintf(writer, "%d ", i)
				}

				fmt.Fprintln(writer)

			} else {
				fmt.Fprintln(writer, -1)
			}
		}
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
4
1
1
1
0
3
1 1 1
3
0 1 1
---
2 1
1 2
4 3 2 1
-1

*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		first := false
		last := false

		for i := 0; i < n; i++ {
			var num int
			scanf("%d", &num)

			if i == 0 && num == 1 {
				last = true
			}

			if i == n-1 && num == 0 {
				first = true
			}
		}
		scanf("\n")

		if first {
			for i := 1; i <= n+1; i++ {
				fmt.Fprintf(writer, "%d ", i)
			}
			fmt.Fprintln(writer)
		} else if last {
			for i := n + 1; i >= 1; i-- {
				fmt.Fprintf(writer, "%d ", i)
			}
			fmt.Fprintln(writer)
		} else {
			fmt.Fprintln(writer, -1)
		}
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
2
1
1
1
0
---
2 1
1 2

*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		first := false
		last := false

		for i := 0; i < n; i++ {
			var num int
			scanf("%d", &num)

			if i == n-1 && num == 0 {
				first = true
			} else if i == 0 && num == 1 {
				last = true
			}
		}
		scanf("\n")

		if first {
			for i := 0; i <= n; i++ {
				fmt.Fprintf(writer, "%d ", i+1)
			}
			fmt.Fprintln(writer)
		} else if last {
			for i := n; i >= 0; i-- {
				fmt.Fprintf(writer, "%d ", i+1)
			}
			fmt.Fprintln(writer)
		} else {
			fmt.Fprintln(writer, -1)
		}
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*

 */

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		for i := 0; i < n; i++ {
			var num int
			scanf("%d", &num)
		}
		scanf("\n")

		for i := 0; i <= n; i++ {
			fmt.Fprintf(writer, "%d ", i+1)
		}
		fmt.Fprintln(writer)
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import "fmt"

func solve() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	if arr[0] == 1 {
		fmt.Printf("%d ", n+1)
		for i := 1; i <= n; i++ {
			fmt.Printf("%d ", i)
		}
	} else if arr[n-1] == 0 {
		for i := 1; i <= n+1; i++ {
			fmt.Printf("%d ", i)
		}
	} else {
		found := false
		for i := 0; i < n-1 && !found; i++ {
			if arr[i] == 0 && arr[i+1] == 1 {
				found = true
				for j := 1; j <= i+1; j++ {
					fmt.Printf("%d ", i)
				}
				fmt.Printf("%d ", n+1)
				for j := i + 2; j <= n; j++ {
					fmt.Printf("%d ", j)
				}
			}
		}
		if !found {
			fmt.Print(-1)
		}
	}
	fmt.Println()
}

func main() {
	var t int
	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import "fmt"

func solve() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	if arr[0] == 1 {
		fmt.Printf("%d ", n+1)
		for i := 1; i <= n; i++ {
			fmt.Printf("%d ", i)
		}
	} else if arr[n-1] == 0 {
		for i := 1; i <= n+1; i++ {
			fmt.Printf("%d ", i)
		}
	} else if n == 3 {
		fmt.Print("1 3 2")
	} else {
		fmt.Print("-1")
	}
	fmt.Println()
}

func main() {
	var t int
	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import "fmt"

func solve() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	if arr[0] == 1 {
		fmt.Printf("%d ", n+1)
		for i := 1; i <= n; i++ {
			fmt.Printf("%d ", i)
		}
	} else if arr[n-1] == 0 {
		for i := 1; i <= n+1; i++ {
			fmt.Printf("%d ", i)
		}
	} else {
		fmt.Print(-1)
	}
	fmt.Println()
}

func main() {
	var t int
	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)

		ARR := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &ARR[i])
		}
		if n > 1 {
			if ARR[0] == 1 {
				fmt.Println(n + 1)
				for i := 1; i < n+1; i++ {
					fmt.Println(i)
				}
			} else {
				if ARR[n-1] == 0 {
					for i := 1; i < n+1; i++ {
						fmt.Println(i)
					}
					fmt.Println(n + 1)
				} else {
					q := 0
					turn := 0
					for i := 1; i < n-1; i++ {
						if ARR[i] == 0 && ARR[i+1] == 1 {
							q = 1
							turn = i + 1
							break
						}
					}
					if q == 0 {
						fmt.Println(-1)
					} else {
						for i := 1; i <= turn; i++ {
							fmt.Println(i)
						}
						fmt.Println(n + 1)
						for i := turn + 1; i < n+1; i++ {
							fmt.Println(i)
						}
					}
				}
			}
		} else {
			if ARR[0] == 0 {
				fmt.Println(1)
				fmt.Println(2)
			} else {
				fmt.Println(2)
				fmt.Println(1)

			}
		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)

		ARR := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &ARR[i])
		}
		if n > 1 {
			if ARR[0] == 1 {
				fmt.Println(n + 1)
				for i := 1; i < n+1; i++ {
					fmt.Println(i)
				}
			} else {
				if ARR[n-1] == 0 {
					for i := 1; i < n+1; i++ {
						fmt.Println(i)
					}
					fmt.Println(n + 1)
				} else {
					fmt.Println(-1)
				}
			}
		} else {
			if ARR[0] == 0 {
				fmt.Println(1)
				fmt.Println(2)
			} else {
				fmt.Println(2)
				fmt.Println(1)

			}
		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)

		ARR := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &ARR[i])
		}
		if ARR[0] == 1 {
			fmt.Println(n + 1)
			for i := 1; i < n+1; i++ {
				fmt.Println(i)
			}
		} else {
			if ARR[n-1] == 0 {
				for i := 1; i < n+1; i++ {
					fmt.Println(i)
				}
				fmt.Println(n + 1)
			} else {
				fmt.Println(-1)
			}
		}

	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Fscan(in,&n)
		var a [30005]int
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		start :=-1
		for i:=1;i<=n;i++{
			if i==n{
				if a[i]==0&&a[1]==1{
					start = i
				}
			}else{
				if a[i]==0&&a[i+1]==1{
					start=i
				}
			}
		}
		ans := []int{}
		if start !=-1 {
			now := start
			for i:=1;i<now;i++{
				ans = append(ans,i)
			}
			ans = append(ans, now)
			ans = append(ans,n+1)
			for i:=now+1;i<=n;i++ {
				ans = append(ans, i)
			}
		}else if a[1]==1{
			ans = append(ans,n+1)
			for i:=1;i<=n;i++{
				ans = append(ans,i)
			}
		}else if a[n]==1{
			for i:=1;i<=n+1;i++{
				ans = append(ans,i)
			}
		}else if a[1]==0&&n==1{
			ans = append(ans,1)
			ans = append(ans,2)
		}
		if len(ans)==0{
			fmt.Fprintln(out,-1)
		}else{
			for i:=0;i<len(ans);i++{
				fmt.Fprintf(out,"%d ",ans[i])
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Fscan(in,&n)
		var a [30005]int
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		start :=-1
		for i:=1;i<=n;i++{
			if i==n{
				if a[i]==0&&a[1]==1{
					start = i
				}
			}else{
				if a[i]==0&&a[i+1]==1{
					start=i
				}
			}
		}
		ans := []int{}
		if start !=-1 {
			now := start
			for i:=1;i<now;i++{
				ans = append(ans,i)
			}
			ans = append(ans, now)
			ans = append(ans,n+1)
			for i:=now+1;i<=n;i++ {
				ans = append(ans, i)
			}
		}else if a[1]==1{
			ans = append(ans,n+1)
			for i:=1;i<=n;i++{
				ans = append(ans,i)
			}
		}else if a[n]==1{
			for i:=1;i<=n+1;i++{
				ans = append(ans,i)
			}
		}
		if len(ans)==0{
			fmt.Fprintln(out,-1)
		}else{
			for i:=0;i<len(ans);i++{
				fmt.Fprintf(out,"%d ",ans[i])
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Fscan(in,&n)
		var a [30005]int
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		start :=-1
		for i:=1;i<=n;i++{
			if i==n{
				if a[i]==0&&a[1]==1{
					start = i
				}
			}else{
				if a[i]==0&&a[i+1]==1{
					start=i
				}
			}
		}
		ans := []int{}
		if start !=-1 {
			now := start
			for i:=1;i<now;i++{
				ans = append(ans,i)
			}
			ans = append(ans, now)
			ans = append(ans,n+1)
			for i:=now+1;i<=n;i++ {
				ans = append(ans, i)
			}
		}else if a[1]==1{
			ans = append(ans,n+1)
			for i:=1;i<=n;i++{
				ans = append(ans,i)
			}
		}else if a[n]==1{
			for i:=1;i<=n;i++{
				ans = append(ans,i)
			}
		}
		if len(ans)==0{
			fmt.Fprintln(out,-1)
		}else{
			for i:=0;i<len(ans);i++{
				fmt.Fprintf(out,"%d ",ans[i])
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Fscan(in,&n)
		var a [30005]int
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		start :=-1
		for i:=1;i<=n;i++{
			if i==n{
				if a[i]==0&&a[1]==1{
					start = i
				}
			}else{
				if a[i]==0&&a[i+1]==1{
					start=i
				}
			}
		}
		ans := []int{}
		if start !=-1 {
			now := start
			for i:=1;i<now;i++{
				ans = append(ans,i)
			}
			ans = append(ans, now)
			ans = append(ans,n+1)
			for i:=now+1;i<=n;i++ {
				ans = append(ans, i)
			}
		}else if a[1]==1{
			ans = append(ans,n+1)
			for i:=1;i<=n;i++{
				ans = append(ans,i)
			}
		}
		if len(ans)==0{
			fmt.Fprintln(out,-1)
		}else{
			for i:=0;i<len(ans);i++{
				fmt.Fprintf(out,"%d ",ans[i])
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {
		var n int
		fmt.Fscan(r, &n)

		a := make([]int, n)
		for i := range a { fmt.Fscan(r, &a[i]) }

		if a[n-1] == 0 {
			for i := 1; i <= n+1; i++ {
				fmt.Fprintf(w, "%d ", i)
			}
			fmt.Fprintln(w, "")
		} else if a[0] == 1 {
			fmt.Fprintf(w, "%d ", n+1)
			for i := 1; i <= n; i++ {
				fmt.Fprintf(w, "%d ", i)
			}
			fmt.Fprintln(w, "")
		} else {
			var x int
			for i := 1; i < n; i++ {
				if a[i] == 1 && a[i-1] == 0 {
					x = i
					break
				}
			}
			if x == 0 {
				fmt.Fprintln(w, -1)
			} else {
				for i := 1; i < x; i++ {
					fmt.Fprintf(w, "%d ", i)
				}
				fmt.Fprintf(w, "%d ", n+1)
				for i := x; i <= n; i++ {
					fmt.Fprintf(w, "%d ", i)
				}
				fmt.Fprintln(w, "")
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {
		var n int
		fmt.Fscan(r, &n)

		a := make([]int, n)
		for i := range a { fmt.Fscan(r, &a[i]) }

		if a[n-1] == 0 {
			for i := 1; i <= n+1; i++ {
				fmt.Fprintf(w, "%d ", i)
			}
			fmt.Fprintln(w, "")
		} else if a[0] == 1 {
			fmt.Fprintf(w, "%d ", n+1)
			for i := 1; i <= n; i++ {
				fmt.Fprintf(w, "%d ", i)
			}
			fmt.Fprintln(w, "")
		} else {
			var x int
			for i := 1; i < n; i++ {
				if a[i] == 1 && a[i-1] == 0 {
					x = i
					break
				}
			}
			if x == 0 {
				fmt.Fprintln(w, -1)
			} else {
				for i := 1; i < x; i++ {
					fmt.Fprintf(w, "%d ", i)
				}
				fmt.Fprintln(w, "%d ", n+1)
				for i := x; i <= n; i++ {
					fmt.Fprintf(w, "%d ", i)
				}
				fmt.Fprintln(w, "")
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	var t int
	var n int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		scanf("%d\n", &n)

		var nums []int
		var temp int

		for j := 0; j < n-1; j++ {
			scanf("%d", &temp)
			nums = append(nums, temp)
		}
		scanf("%d\n", &temp)
		nums = append(nums, temp)

		if nums[len(nums)-1] == 0 {
			for k := 0; k < n; k++ {
				fmt.Print(k+1, " ")
			}
			fmt.Println(n+1)
		} else {
			for k := 0; k < n-1; k++ {
				fmt.Print(k+1, " ")
			}
			fmt.Println(n+1, n)
		}

	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	defer wr.Flush()
	t := scanInt()
	for i := 0; i < t; i++ {
		s := solve()
		if s == nil {
			fmt.Fprintln(wr, -1)
			continue
		}
		for i, v := range s {
			if i > 0 {
				fmt.Fprint(wr, " ")
			}
			fmt.Fprint(wr, v)
		}
		fmt.Fprint(wr, "\n")
	}
}

func solve() []int {
	n := scanInt()
	a := make([]int, n)
	p, q, r := false, false, false
	qi := -1
	for i := 0; i < n; i++ {
		a[i] = scanInt()
		if i == 1 && a[i-1] == 1 {
			p = true
		} else if i > 0 && (a[i-1] == 0 && a[i] == 1) {
			qi = i
			q = true
		} else if i == n-1 && a[i] == 0 {
			r = true
		}
	}
	if !p && !q && !r {
		return nil
	}

	ret := make([]int, 0, n+1)
	if p {
		ret = append(ret, n+1)
		for i := 1; i <= n; i++ {
			ret = append(ret, i)
		}
	} else if r {
		for i := 1; i <= n+1; i++ {
			ret = append(ret, i)
		}
	} else if q {
		for i := 1; i <= qi; i++ {
			ret = append(ret, i)
		}
		ret = append(ret, n+1)
		for i := qi + 1; i <= n; i++ {
			ret = append(ret, i)
		}
	}
	return ret
}

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

func scanInt() int {
	sc.Scan()
	ret, _ := strconv.Atoi(sc.Text())
	return ret
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	defer wr.Flush()
	t := scanInt()
	for i := 0; i < t; i++ {
		s := solve()
		if s == nil {
			fmt.Fprintln(wr, -1)
			continue
		}
		for i, v := range s {
			if i > 0 {
				fmt.Fprint(wr, " ")
			}
			fmt.Fprint(wr, v)
		}
		fmt.Fprint(wr, "\n")
	}
}

func solve() []int {
	n := scanInt()
	a := make([]int, n)
	p, q, r := false, false, false
	qi := -1
	for i := 0; i < n; i++ {
		a[i] = scanInt()
		if i == 1 && a[i-1] == 1 {
			p = true
		} else if i > 0 && (a[i-1] == 0 && a[i] == 1) {
			qi = i - 1
			q = true
		} else if i == n-1 && a[i] == 0 {
			r = true
		}
	}
	if !p && !q && !r {
		return nil
	}

	ret := make([]int, 0, n+1)
	if p {
		ret = append(ret, n+1)
		for i := 1; i <= n; i++ {
			ret = append(ret, i)
		}
	} else if r {
		for i := 1; i <= n+1; i++ {
			ret = append(ret, i)
		}
	} else if q {
		for i := 1; i <= qi; i++ {
			ret = append(ret, i)
		}
		ret = append(ret, n+1)
		for i := qi + 1; i <= n; i++ {
			ret = append(ret, i)
		}
	}
	return ret
}

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

func scanInt() int {
	sc.Scan()
	ret, _ := strconv.Atoi(sc.Text())
	return ret
}

// 00
package main

import (
	"bufio"
	"fmt"
	"os"
)

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		to := map[int]bool{}
		from := map[int]bool{}
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
			if a[i] == 0 {
				to[i] = true
			} else {
				from[i] = true
			}
		}
		ok := false
		div := -1
		for i := 0; i < n-1; i++ {
			if to[i] && from[i+1] {
				ok = true
				div = i + 1
				break
			}
		}
		if a[0] == 1 {
			write(f, n+1, " ")
			for i := 1; i <= n; i++ {
				write(f, i)
				if i == n {
					write(f, "\n")
				} else {
					write(f, " ")
				}
			}
		} else if ok {
			for i := 1; i <= n; i++ {
				write(f, i)
				if i == div {
					write(f, " ", n+1)
				}
				if i == n {
					write(f, "\n")
				} else {
					write(f, " ")
				}
			}
		} else {
			write(f, "-1\n")
		}

	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T int

	fmt.Fscanf(r, "%d\n", &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscanf(r, "%d\n", &n)
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscanf(r, "%d", &v)
		}
		fmt.Fscanf(r, "\n")

		for i := 1; i <= n+1; i++ {
			if i != 1 {
				fmt.Print(" ")
			}
			fmt.Print(i)
		}
		fmt.Println()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

/* --- Solution C --- */
func solve(in *In, out *Out) {
	n := in.nextInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		v := in.nextInt()
		a[i] = v
	}

	if a[n-1] == 0 {
		for i := 1; i <= n+1; i++ {
			out.printf("%d ", i)
		}
		out.print("\n")
		return
	}
	if a[0] == 1 {
		out.printf("%d ", n+1)
		for i := 1; i <= n; i++ {
			out.printf("%d ", i)
		}
		out.print("\n")
		return
	}
	for i := 0; i < n-1; i++ {
		if a[i] == 0 && a[i+1] == 1 {
			for j := 1; j <= i+1; j++ {
				out.printf("%d ", j)
			}
			out.print(n + 1)
			for j := i + 2; j <= n; j++ {
				out.printf("%d ", j)
			}
			out.print("\n")
			return
		}
	}
	out.println(-1)
}

func run(in *In, out *Out) {
	cases(in, out)
	// solve(in, out)
}

func main() {
	in := NewIn()
	out := NewOut()
	defer out.flush()

	run(in, out)
}

func cases(in *In, out *Out) {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve(in, out)
	}
}

/* --- I/O --- */
const BUF_MAX_CAP int = 1024

type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	scn := bufio.NewScanner(os.Stdin)

	buf := make([]byte, BUF_MAX_CAP)
	scn.Buffer(buf, BUF_MAX_CAP)
	scn.Split(bufio.ScanWords)

	return &In{scn}
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

func (in *In) nextByte() byte {
	in.scanner.Scan()
	return in.scanner.Text()[0]
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

func (out *Out) println(a ...interface{}) {
	fmt.Fprintln(out.writer, a...)
}

func (out *Out) printf(format string, a ...interface{}) {
	fmt.Fprintf(out.writer, format, a...)
}

func (out *Out) print(a ...interface{}) {
	fmt.Fprint(out.writer, a...)
}

func (out *Out) flush() {
	out.writer.Flush()
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var sherlockCc string
	var moriartyCc string
	fmt.Scanf("%d\n", &n)
	fmt.Scanf("%s\n", &sherlockCc)
	fmt.Scanf("%s\n", &moriartyCc)

	sCcBytes := []byte(sherlockCc)
	mCcBytes := []byte(moriartyCc)

	sort.Slice(sCcBytes, func(i, j int) bool { return sCcBytes[i] < sCcBytes[j] })
	sort.Slice(mCcBytes, func(i, j int) bool { return mCcBytes[i] < mCcBytes[j] })

	mn := 0
	j := 0
	for i := 0; i < n; i++ {
		for j < n && sCcBytes[i] > mCcBytes[j] {
			mn++
			j++
		}
		j++
	}
	mx := 0
	j = 0
	for i := 0; i < n; i++ {
		for j < n && sCcBytes[i] >= mCcBytes[j] {
			j++
		}
		if j < n {
			mx++
		}
		j++
	}
	fmt.Println(mn)
	fmt.Println(mx)
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func Solve(io *FastIO) {
	io.NextInt()
	S := io.NextLine()
	M := io.NextLine()

	sfd := MakeFreqs(S)
	mfd := MakeFreqs(M)
	sfo := make([]int, 10)
	mfo := make([]int, 10)
	copy(sfo, sfd)
	copy(mfo, mfd)

	io.Printf("%d %d\n", CountDefense(sfd, mfd), CountOffense(sfo, mfo))
}

func CountDefense(sf, mf []int) int {
	hits := 0
	for si, mi := 9, 9; ; {

		for si >= 0 && sf[si] == 0 {
			si--
		}
		for mi >= 0 && mf[mi] == 0 {
			mi--
		}

		if si < 0 || mi < 0 {
			break
		}

		if mi < si {
			hits++
		} else {
			mf[mi]--
		}
		sf[si]--
	}
	return hits
}

func CountOffense(sf, mf []int) int {
	hits := 0
	for si, mi := 9, 9; ; {

		for si >= 0 && sf[si] == 0 {
			si--
		}
		for mi >= 0 && mf[mi] == 0 {
			mi--
		}

		if si < 0 || mi < 0 {
			break
		}

		if mi > si {
			hits++
			mf[mi]--
		}
		sf[si]--
	}
	return hits
}

func MakeFreqs(s string) []int {
	f := make([]int, 10)
	for _, c := range s {
		f[c - '0']++
	}
	return f
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

func IsLineBreakChar(c byte) bool {
	switch c {
		case 0, '\n', '\r':
			return true
		default:
			return false
	}
}

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Solve(&io)
	io.FlushOutput()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextLine()
	B := sc.NextLine()

	C := make([]int, N)
	for i := 0; i < N; i++ {
		C[i], _ = strconv.Atoi(string(A[i]))
	}

	D := make([]int, N)
	for i := 0; i < N; i++ {
		D[i], _ = strconv.Atoi(string(B[i]))
	}

	sort.Ints(C)
	sort.Ints(D)

	j := 0
	i := 0
	for i < N && j < N {
		for j < N && C[i] > D[j] {
			j++
		}
		if j < N {
			j++
			i++
		}
	}

	ans1 := j - i

	j = 0
	i = 0
	for i < N && j < N {
		for ; j < N; j++ {
			if C[i] < D[j] {
				break
			}
		}
		if j == N {
			break
		}
		i++
		j++
	}
	fmt.Println(ans1)
	fmt.Println(N - (j - i))

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	n, a := sc.NextInt(), sc.NextInt()

	if n == 3 {
		fmt.Println(1, 2, 3)
		return
	}
	mn := 180.0
	index := n
	base := float64(180) / float64(n)
	for i := 1; i <= n-2; i++ {
		b := math.Abs(float64(a) - base*float64(i))
		if mn > b {
			mn = b
			index = i
		}
	}

	fmt.Println(2, 1, 2+index)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

// Codeforces My Practice
// author: Leonardone @ NEETSDKASU
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, a float64
	fmt.Scan(&n, &a)
	min := float64(9999)
	ans := 0
	for i := 3; i <= int(n); i++ {
		rad := float64(i-2) * 180 / n
		dif := math.Abs(rad - a)
		if dif < min {
			min = dif
			ans = i
		}
	}
	fmt.Println(2, 1, ans)
}

// Try Codeforces
// author: Leonardone @ NEETSDKASU
package main

import (
	"fmt"
	"math"
	"math/cmplx"
)

type vec struct{ x, y float64 }

func main() {
	var n, a float64
	fmt.Scan(&n, &a)
	a = a * math.Pi / 180
	v := 180 * (n - 2) / n
	dv := (180 - v) * math.Pi / 180
	vs := make([]complex128, int(n))
	for i := range vs {
		vs[i] = cmplx.Rect(1, dv*float64(i))
		if i > 0 {
			vs[i] += vs[i-1]
		}
	}
	min := float64(9999)
	ans := "1 2 3"
	for i := 1; i < int(n); i++ {
		x := vs[i-1]
		for j := i; j < int(n); j++ {
			_, t := cmplx.Polar(vs[j] - x)
			df := math.Abs(t - a)
			if df < min {
				min = df
				ans = fmt.Sprintf("%d 1 %d", i+1, j+2)
			}
		}
	}
	fmt.Println(ans)
}

// Try Codeforces
// author: Leonardone @ NEETSDKASU
package main

import (
	"fmt"
	"math"
	"math/cmplx"
)

type vec struct{ x, y float64 }

func main() {
	var n, a float64
	fmt.Scan(&n, &a)
	v := 180 * (n - 2) / n
	dv := (180 - v) * math.Pi / 180
	vs := make([]complex128, int(n))
	min := float64(9999)
	p := 0
	for i := range vs {
		vs[i] = cmplx.Rect(1, dv*float64(i))
		if i > 0 {
			vs[i] += vs[i-1]
		}
		if i < 1 {
			continue
		}
		_, t := cmplx.Polar(vs[i])
		t = t * 180 / math.Pi
		df := math.Abs(t - a)
		if df < min {
			min = df
			p = i + 2
		}
		//fmt.Println(i+1, t)
	}
	fmt.Println(p, 1, 2)
}

// Try Codeforces
// author: Leonardone @ NEETSDKASU
package main

import (
	"fmt"
	"math"
	"math/cmplx"
)

type vec struct{ x, y float64 }

func main() {
	var n, a float64
	fmt.Scan(&n, &a)
	v := 180 * (n - 2) / n
	dv := (180 - v) * math.Pi / 180
	vs := make([]complex128, int(n))
	min := float64(9999)
	p := 0
	for i := range vs {
		vs[i] = cmplx.Rect(1, dv*float64(i))
		if i > 0 {
			vs[i] += vs[i-1]
		}
		if i < 1 {
			continue
		}
		_, t := cmplx.Polar(vs[i])
		t = t * 180 / math.Pi
		df := math.Abs(t - a)
		if df < min {
			min = df
			p = i + 2
		}
		//fmt.Println(i+1, t)
	}
	fmt.Println(2, 1, p)
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	n, a := sc.NextInt(), sc.NextInt()

	if n == 3 {
		fmt.Println(1, 2, 3)
		return
	}
	mn := 180.0
	index := n
	base := float64(180) / float64(n)
	for i := 0; i <= n-2; i++ {
		b := math.Abs(float64(a) - base*float64(i))
		if mn > b {
			mn = b
			index = i
		}
	}

	fmt.Println(2, 1, 2+index)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	n, a := sc.NextInt(), sc.NextInt()

	if n == 3 {
		fmt.Println(1, 2, 3)
		return
	}
	mn := 180.0
	index := n
	base := float64((1.0 * (1.0 * (n - 2)) * 180) / n)
	for i := 1; i <= n-2; i++ {
		b := math.Abs(float64(a) - base/float64(i))
		if mn > b {
			mn = b
			index = i
		}
	}

	fmt.Println(2, 1, n-(index-1))
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	n, a := sc.NextInt(), sc.NextInt()

	if n == 3 {
		fmt.Println(1, 2, 3)
		return
	}
	mn := 180.0
	index := n
	base := float64((1.0*(1.0*(n-2))*180)/n) / float64(n-2)
	for i := 1; i <= n-2; i++ {
		b := math.Abs(float64(a) - base*float64(i))
		if mn > b {
			mn = b
			index = i
		}
	}

	fmt.Println(2, 1, 2+index)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	n, a := sc.NextInt(), sc.NextInt()

	if n == 3 {
		fmt.Println(1, 2, 3)
		return
	}
	mn := 180.0
	index := 9
	base := float64((1.0 * (1.0 * (n - 2)) * 180) / n)
	for i := 1; i <= n-2; i++ {
		b := math.Abs(float64(a) - base/float64(i))
		if mn > b {
			mn = b
			index = i
		}
	}

	fmt.Println(2, 1, n-(index-1))
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	n, a := sc.NextInt(), sc.NextInt()

	if n == 3 {
		fmt.Println(1, 2, 3)
		return
	}
	mn := 180.0
	index := n
	base := float64((1.0*(1.0*(n-2))*180)/n) / float64(n-2)
	for i := 0; i <= n-2; i++ {
		b := math.Abs(float64(a) - base*float64(i))
		if mn > b {
			mn = b
			index = i
		}
	}

	fmt.Println(2, 1, 2+index)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

var m map[int][]int

func main() {
	defer writer.Flush()

	a := []int{4, 8, 15, 16, 23, 42}
	m = make(map[int][]int)
	for _, i := range a {
		for _, j := range a {
			if i > j {
				m[i*j] = []int{j, i}
				continue
			}
			m[i*j] = []int{i, j}
		}
	}

	ans := make([]int, 6)
	ansMap := map[int]struct{}{}

	var resp int
	printf("? 1 2\n")
	writer.Flush()
	scanf("%v\n", &resp)
	v := m[resp]
	ans[0] = v[0]
	ans[1] = v[1]
	ansMap[v[0]] = struct{}{}
	ansMap[v[1]] = struct{}{}

	printf("? 2 3\n")
	writer.Flush()
	scanf("%v\n", &resp)
	v = m[resp]
	if _, ok := ansMap[v[0]]; !ok {
		ans[2] = v[0]
		ansMap[v[0]] = struct{}{}
	} else {
		ans[2] = v[1]
		ansMap[v[1]] = struct{}{}
	}
	if ans[1]*ans[2] != resp {
		ans[0], ans[1] = ans[1], ans[0]
	}

	printf("? 3 4\n")
	writer.Flush()
	scanf("%v\n", &resp)
	v = m[resp]
	if _, ok := ansMap[v[0]]; !ok {
		ans[3] = v[0]
		ansMap[v[0]] = struct{}{}
	} else {
		ans[3] = v[1]
		ansMap[v[1]] = struct{}{}
	}

	printf("? 4 5\n")
	writer.Flush()
	scanf("%v\n", &resp)
	v = m[resp]
	if _, ok := ansMap[v[0]]; !ok {
		ans[4] = v[0]
		ansMap[v[0]] = struct{}{}
	} else {
		ans[4] = v[1]
		ansMap[v[1]] = struct{}{}
	}

	for _, v := range a {
		if _, ok := ansMap[v]; !ok {
			ans[5] = v
			break
		}
	}

	printf("! %d %d %d %d %d %d\n", ans[0], ans[1], ans[2], ans[3], ans[4], ans[5])
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve(j Jam) {
	j.PF("? 1 2\n")
	p01 := j.Int()
	j.PF("? 2 3\n")
	p12 := j.Int()
	j.PF("? 3 4\n")
	p23 := j.Int()
	j.PF("? 4 5\n")
	p34 := j.Int()

	nums := [6]int64{4, 8, 15, 16, 23, 42}
	perm := PermNew(6)

	for {
		t01 := nums[perm[0]] * nums[perm[1]]
		t12 := nums[perm[1]] * nums[perm[2]]
		t23 := nums[perm[2]] * nums[perm[3]]
		t34 := nums[perm[3]] * nums[perm[4]]
		if p01 == t01 && p12 == t12 && p23 == t23 && p34 == t34 {
			fmt.Printf("! %d %d %d %d %d %d\n",
				nums[perm[0]], nums[perm[1]],
				nums[perm[2]], nums[perm[3]],
				nums[perm[4]], nums[perm[5]],
			)
			return
		}
		if !perm.Next() {
			panic("not possible")
		}
	}
}

func main() {
	jam, closeFunc := JamNew()
	defer closeFunc()
	solve(jam)
}

type Jam interface {
	Scanner() *bufio.Scanner
	Writer() *bufio.Writer
	Close()

	Str() string
	Int() int64
	Float() float64

	P(format string, values ...interface{})
	PF(format string, values ...interface{})
}

func JamNew() (Jam, func()) {
	if len(os.Args) > 1 {
		panic("running with input file path is not supported")
	}

	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriter(os.Stdout)
	jam := &jam{scanner, writer}
	return jam, jam.Close
}

type jam struct {
	sc *bufio.Scanner
	wr *bufio.Writer
}

func (j *jam) Close() {
	if err := j.wr.Flush(); err != nil {
		panic(err)
	}
}

func (j *jam) Scanner() *bufio.Scanner {
	return j.sc
}

func (j *jam) Writer() *bufio.Writer {
	return j.wr
}

func (j *jam) Str() string {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	return j.sc.Text()
}

func (j *jam) Int() int64 {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	res, err := strconv.ParseInt(j.sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}

	return res
}

func (j *jam) Float() float64 {
	j.sc.Scan()
	res, err := strconv.ParseFloat(j.sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (j *jam) P(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
}

func (j *jam) PF(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
	if err = j.wr.Flush(); err != nil {
		panic(err)
	}
}

//	GoLang shorthand methods for math go below
//	TODO wipe unused methods before submitting

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

type Perm []uint32

func PermNew(size int) Perm {
	perm := make([]uint32, size)
	for i := range perm {
		perm[i] = uint32(i)
	}
	return perm
}

//	https://www.nayuki.io/page/next-lexicographical-permutation-algorithm

func (perm Perm) Next() bool {
	rollPos := len(perm) - 2
	for rollPos >= 0 && perm[rollPos] > perm[rollPos+1] {
		rollPos -= 1
	}
	if rollPos < 0 {
		return false
	}

	swapPos := rollPos + 1
	for pos := rollPos + 2; pos < len(perm); pos++ {
		if perm[rollPos] < perm[pos] && perm[pos] < perm[swapPos] {
			swapPos = pos
		}
	}
	perm[rollPos], perm[swapPos] = perm[swapPos], perm[rollPos]

	for i, j := rollPos+1, len(perm)-1; i < j; i, j = i+1, j-1 {
		perm[i], perm[j] = perm[j], perm[i]
	}

	return true
}

package main

import (
	"fmt"
	"os"
)

func perm(ori []int, cur []int, vis []bool, pos int, res *[][]int) {
	if pos == len(ori) {
		*res = append(*res, append([]int{}, cur...))
		return
	}
	for i := 0; i < len(ori); i++ {
		if !vis[i] {
			vis[i] = true
			cur[pos] = ori[i]
			perm(ori, cur, vis, pos+1, res)
			vis[i] = false
		}
	}
}

func main() {
	ori := []int{4, 8, 15, 16, 23, 42}
	res := [][]int{}

	perm(ori, make([]int, len(ori)), make([]bool, len(ori)), 0, &res)

	m := make(map[string]int)
	for i := 0; i < len(res); i++ {
		cur := res[i]
		key := fmt.Sprintf("%d,%d,%d,%d", cur[0]*cur[1], cur[2]*cur[3], cur[0]*cur[4], cur[2]*cur[4])
		m[key] = i
	}

	var q1, q2, q3, q4 int

	fmt.Printf("? 1 2\n")
	os.Stdout.Sync()
	fmt.Scanf("%d\n", &q1)

	fmt.Printf("? 3 4\n")
	os.Stdout.Sync()
	fmt.Scanf("%d\n", &q2)

	fmt.Printf("? 1 5\n")
	os.Stdout.Sync()
	fmt.Scanf("%d\n", &q3)

	fmt.Printf("? 3 5\n")
	os.Stdout.Sync()
	fmt.Scanf("%d\n", &q4)

	//fmt.Printf("%d %d %d %d", q1, q2, q3, q4)

	key := fmt.Sprintf("%d,%d,%d,%d", q1, q2, q3, q4)
	if v, ok := m[key]; ok {
		fmt.Printf("! %d %d %d %d %d %d\n", res[v][0], res[v][1], res[v][2], res[v][3], res[v][4], res[v][5])
		os.Stdout.Sync()
	}
}