The city where Mocha lives in is called Zhijiang. There are $$$n+1$$$ villages and $$$2n-1$$$ directed roads in this city. There are two kinds of roads:  $$$n-1$$$ roads are from village $$$i$$$ to village $$$i+1$$$, for all $$$1\leq i \leq n-1$$$.  $$$n$$$ roads can be described by a sequence $$$a_1,\ldots,a_n$$$. If $$$a_i=0$$$, the $$$i$$$-th of these roads goes from village $$$i$$$ to village $$$n+1$$$, otherwise it goes from village $$$n+1$$$ to village $$$i$$$, for all $$$1\leq i\leq n$$$. Mocha plans to go hiking with Taki this weekend. To avoid the trip being boring, they plan to go through every village exactly once. They can start and finish at any villages. Can you help them to draw up a plan?

Each test contains multiple test cases.  The first line contains a single integer $$$t$$$ ($$$1 \le t \le 20$$$) — the number of test cases. Each test case consists of two lines. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^4$$$) — indicates that the number of villages is $$$n+1$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 1$$$). If $$$a_i=0$$$, it means that there is a road from village $$$i$$$ to village $$$n+1$$$. If $$$a_i=1$$$, it means that there is a road from village $$$n+1$$$ to village $$$i$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^4$$$.

For each test case, print a line with $$$n+1$$$ integers, where the $$$i$$$-th number is the $$$i$$$-th village they will go through. If the answer doesn't exist, print $$$-1$$$. If there are multiple correct answers, you can print any one of them.

NoteIn the first test case, the city looks like the following graph:So all possible answers are $$$(1 \to 4 \to 2 \to 3)$$$, $$$(1 \to 2 \to 3 \to 4)$$$.In the second test case, the city looks like the following graph:So all possible answers are $$$(4 \to 1 \to 2 \to 3)$$$, $$$(1 \to 2 \to 3 \to 4)$$$, $$$(3 \to 4 \to 1 \to 2)$$$, $$$(2 \to 3 \to 4 \to 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 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 "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"
)

// 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"
	"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
}

// 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() {
	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"
	//"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"
)

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 (
	"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"
	"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()
}


After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards.Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick.Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks.Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies.

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits — Sherlock's credit card number. The third line contains n digits — Moriarty's credit card number.

First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty.

NoteFirst sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.

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
		}
	}
}


It's a very unfortunate day for Volodya today. He got bad mark in algebra and was therefore forced to do some work in the kitchen, namely to cook borscht (traditional Russian soup). This should also improve his algebra skills.According to the borscht recipe it consists of n ingredients that have to be mixed in proportion  litres (thus, there should be a1 ·x, ..., an ·x litres of corresponding ingredients mixed for some non-negative x). In the kitchen Volodya found out that he has b1, ..., bn litres of these ingredients at his disposal correspondingly. In order to correct his algebra mistakes he ought to cook as much soup as possible in a V litres volume pan (which means the amount of soup cooked can be between 0 and V litres). What is the volume of borscht Volodya will cook ultimately?

The first line of the input contains two space-separated integers n and V (1 ≤ n ≤ 20, 1 ≤ V ≤ 10000). The next line contains n space-separated integers ai (1 ≤ ai ≤ 100). Finally, the last line contains n space-separated integers bi (0 ≤ bi ≤ 100).

Your program should output just one real number — the volume of soup that Volodya will cook. Your answer must have a relative or absolute error less than 10 - 4.

package main

import "fmt"

func main() {
	var n int
	var V float32
	var arr [100]float32
	var have [100]float32
	fmt.Scan(&n, &V)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&have[i])
	}
	var min float32 = 10000000
	for i := 0; i < n; i++ {
		var x float32
		x = have[i] / arr[i]
		if x < min {
			min = x
		}
	}
	var sum float32
	for i := 0; i < n; i++ {
		sum = sum + arr[i]*min
	}
	if sum >V{
		fmt.Printf("%.4f",V)
	}else {
		fmt.Printf("%.4f",sum)
	}

}

package main

import "fmt"

func main() {
	var n int
	var V float32
	var arr [100]float32
	var have [100]float32
	fmt.Scan(&n, &V)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&have[i])
	}
	var min float32 = 10000000
	for i := 0; i < n; i++ {
		var x float32
		x = have[i] / arr[i]
		if x < min {
			min = x
		}
	}
	var sum float32
	for i := 0; i < n; i++ {
		sum = sum + arr[i]*min
	}
	fmt.Printf("%.1f",sum)
}

package main

import "fmt"

func main() {
	var n int
	var V float32
	var arr [100]float32
	var have [100]float32
	fmt.Scan(&n, &V)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&have[i])
	}
	var min float32 = 10000000
	for i := 0; i < n; i++ {
		var x float32
		x = have[i] / arr[i]
		if x < min {
			min = x
		}
	}
	var sum float32
	for i := 0; i < n; i++ {
		sum = sum + arr[i]*min
	}
	if sum >V{
		fmt.Printf("%.1f",V)
	}else {
		fmt.Printf("%.1f",sum)
	}

}


On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle  (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value  should be minimum possible.If there are many optimal solutions, Mister B should be satisfied with any of them.

First and only line contains two space-separated integers n and a (3 ≤ n ≤ 105, 1 ≤ a ≤ 180) — the number of vertices in the polygon and the needed angle, in degrees.

Print three space-separated integers: the vertices v1, v2, v3, which form . If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.

NoteIn first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".

// 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)
}

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
		}
	}
}

// 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
		}
	}
}