Your friend Salem is Warawreh's brother and only loves math and geometry problems. He has solved plenty of such problems, but according to Warawreh, in order to graduate from university he has to solve more graph problems. Since Salem is not good with graphs he asked your help with the following problem.  You are given a complete directed graph with $$$n$$$ vertices without self-loops. In other words, you have $$$n$$$ vertices and each pair of vertices $$$u$$$ and $$$v$$$ ($$$u \neq v$$$) has both directed edges $$$(u, v)$$$ and $$$(v, u)$$$.Every directed edge of the graph is labeled with a single character: either 'a' or 'b' (edges $$$(u, v)$$$ and $$$(v, u)$$$ may have different labels).You are also given an integer $$$m > 0$$$. You should find a path of length $$$m$$$ such that the string obtained by writing out edges' labels when going along the path is a palindrome. The length of the path is the number of edges in it.You can visit the same vertex and the same directed edge any number of times.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq n \leq 1000$$$; $$$1 \leq m \leq 10^{5}$$$) — the number of vertices in the graph and desirable length of the palindrome. Each of the next $$$n$$$ lines contains $$$n$$$ characters. The $$$j$$$-th character of the $$$i$$$-th line describes the character on the edge that is going from node $$$i$$$ to node $$$j$$$. Every character is either 'a' or 'b' if $$$i \neq j$$$, or '*' if $$$i = j$$$, since the graph doesn't contain self-loops. It's guaranteed that the sum of $$$n$$$ over test cases doesn't exceed $$$1000$$$ and the sum of $$$m$$$ doesn't exceed $$$10^5$$$.

For each test case, if it is possible to find such path, print "YES" and the path itself as a sequence of $$$m + 1$$$ integers: indices of vertices in the path in the appropriate order. If there are several valid paths, print any of them. Otherwise, (if there is no answer) print "NO".

5
3 1
*ba
b*b
ab*
3 3
*ba
b*b
ab*
3 4
*ba
b*b
ab*
4 6
*aaa
b*ba
ab*a
bba*
2 6
*a
b*

NoteThe graph from the first three test cases is shown below:  In the first test case, the answer sequence is $$$[1,2]$$$ which means that the path is:$$$$$$1 \xrightarrow{\text{b}} 2$$$$$$So the string that is obtained by the given path is b.In the second test case, the answer sequence is $$$[2,1,3,2]$$$ which means that the path is:$$$$$$2 \xrightarrow{\text{b}} 1 \xrightarrow{\text{a}} 3 \xrightarrow{\text{b}} 2$$$$$$So the string that is obtained by the given path is bab.In the third test case, the answer sequence is $$$[1,3,1,3,1]$$$ which means that the path is:$$$$$$1 \xrightarrow{\text{a}} 3 \xrightarrow{\text{a}} 1 \xrightarrow{\text{a}} 3 \xrightarrow{\text{a}} 1$$$$$$So the string that is obtained by the given path is aaaa.The string obtained in the fourth test case is abaaba.

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, m int
		Fscan(in, &n, &m)
		g := make([][]byte, n)
		for i := range g {
			Fscan(in, &g[i])
		}
		for i, r := range g {
			for j := i + 1; j < n; j++ {
				if r[j] == g[j][i] {
					Fprintln(out, "YES")
					for k := 0; k <= m; k++ {
						if k&1 == 0 {
							Fprint(out, i+1, " ")
						} else {
							Fprint(out, j+1, " ")
						}
					}
					Fprintln(out)
					return
				}
			}
		}
		if n < 3 {
			if m&1 == 0 {
				Fprintln(out, "NO")
				return
			}
			Fprintln(out, "YES")
			for i := 0; i < m; i += 2 {
				Fprint(out, 1, 2, " ")
			}
			Fprintln(out)
			return
		}

		Fprintln(out, "YES")
		if g[0][1] == g[1][2] && g[1][2] == g[2][0] {
			for i := 0; i <= m; i++ {
				Fprint(out, i%3+1, " ")
			}
			Fprintln(out)
			return
		}

		x := [3]int{}
		if g[0][1] == g[0][2] {
			x = [3]int{0, 1, 2}
			if g[1][2] != g[0][1] {
				x = [3]int{0, 2, 1}
			}
		} else if g[1][0] == g[1][2] {
			x = [3]int{1, 0, 2}
			if g[0][2] != g[1][0] {
				x = [3]int{1, 2, 0}
			}
		} else {
			x = [3]int{2, 0, 1}
			if g[0][1] != g[2][0] {
				x = [3]int{2, 1, 0}
			}
		}
		for i := 0; i < 3; i++ {
			x[i]++
		}
		if m%2 > 0 {
			Fprint(out, x[0], " ")
			for i := 0; i < m-1; i += 2 {
				Fprint(out, x[1], x[0], " ")
			}
			Fprintln(out, x[1])
		} else if m%4 == 2 {
			Fprint(out, x[0], " ")
			for i := 0; i < m-2; i += 4 {
				Fprint(out, x[1], x[2], x[1], x[0], " ")
			}
			Fprintln(out, x[1], x[2])
		} else {
			Fprint(out, x[1], " ")
			for i := 0; i < m; i += 4 {
				Fprint(out, x[2], x[1], x[0], x[1], " ")
			}
			Fprintln(out)
		}
	}

	var t int
	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"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n, m := readTwoNums(reader)
		G := make([][]byte, n)
		for i := 0; i < n; i++ {
			G[i], _ = reader.ReadBytes('\n')
		}
		res := solve(n, m, G)

		if len(res) == 0 {
			buf.WriteString("NO\n")
		} else {
			buf.WriteString("YES\n")
			for i := 0; i < len(res); i++ {
				buf.WriteString(fmt.Sprintf("%d ", res[i]))
			}
			buf.WriteByte('\n')
		}
	}
	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int, m int, G [][]byte) []int {
	res := make([]int, m+1)
	if m&1 == 1 {
		for i := 0; i <= m; i++ {
			res[i] = (i & 1) + 1
		}
		//res[m] = 1
		return res
	}
	// then m is even
	var ok bool
	var pivot [2]int

	has := make([][]int, n)
	for i := 0; i < n; i++ {
		has[i] = make([]int, 2)
		for j := 0; j < 2; j++ {
			has[i][j] = -1
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			if G[i][j] == G[j][i] {
				pivot = [...]int{i, j}
				ok = true
			}
			has[i][int(G[i][j]-'a')] = j
		}
	}

	if ok {
		for i := 0; i <= m; i++ {
			res[i] = pivot[i&1] + 1
		}
		return res
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			cur := has[j][int(G[i][j]-'a')]
			if cur < 0 {
				continue
			}
			if (m/2)&1 == 1 {
				for k := 0; k <= m; k++ {
					if k%4 == 0 {
						res[k] = i + 1
					} else if k%4 == 2 {
						res[k] = cur + 1
					} else {
						res[k] = j + 1
					}
				}
			} else {
				var p int
				res[p] = j + 1
				p++
				for k := 0; k < m/2; k++ {
					if k&1 == 1 {
						res[p] = j + 1
					} else {
						res[p] = cur + 1
					}
					p++
				}
				for k := 0; k < m/2; k++ {
					if k&1 == 1 {
						res[p] = j + 1
					} else {
						res[p] = i + 1
					}
					p++
				}
				return res
			}

			return res
		}
	}

	return nil
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n, m int
	var s string
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &m)
		a := make([][]byte, n)
		for i := 0; i < n; i++ {
			a[i] = make([]byte, n)
			fmt.Fscan(in, &s)
			for j := range s {
				if i != j {
					a[i][j] = s[j]
				}
			}
		}
		if m%2 == 1 {
			fmt.Fprintln(out, "YES")
			fmt.Fprint(out, "1 2")
			for i := 1; i < m; i++ {
				if i%2 == 0 {
					fmt.Fprint(out, " 2")
				} else {
					fmt.Fprint(out, " 1")
				}
			}
			fmt.Fprintln(out)
		} else {
			if n == 2 {
				if a[0][1] != a[1][0] {
					fmt.Fprintln(out, "NO")
				} else {
					fmt.Fprintln(out, "YES")
					fmt.Fprint(out, "1 2")
					for i := 1; i < m; i++ {
						if i%2 == 0 {
							fmt.Fprint(out, " 2")
						} else {
							fmt.Fprint(out, " 1")
						}
					}
					fmt.Fprintln(out)
				}
			} else {
				fmt.Fprintln(out, "YES")
				if a[0][1] == a[1][2] && a[0][1] == a[2][0] {
					for i := 0; i <= m; i++ {
						fmt.Fprint(out, i%3+1, " ")
					}
					fmt.Fprintln(out)
				} else if a[0][1] == a[1][0] || a[1][2] == a[2][1] || a[2][0] == a[0][2] {
					if a[0][1] == a[1][0] {
						for i := 0; i <= m; i++ {
							fmt.Fprint(out, i%2+1, " ")
						}
						fmt.Fprintln(out)
					} else if a[1][2] == a[2][1] {
						for i := 0; i <= m; i++ {
							fmt.Fprint(out, i%2+2, " ")
						}
						fmt.Fprintln(out)
					} else if a[2][0] == a[0][2] {
						for i := 0; i <= m; i++ {
							fmt.Fprint(out, (i%2)*2+1, " ")
						}
						fmt.Fprintln(out)
					}
				} else {
					c, l, r := 1, 2, 3
					if a[0][1] == a[1][2] {
						c, l, r = 2, 1, 3
					} else if a[1][2] == a[2][0] {
						c, l, r = 3, 1, 2
					}
					if m%4 == 0 {
						for i := 0; i < m/4; i++ {
							fmt.Fprintf(out, "%d %d %d %d ", c, l, c, r)
						}
						fmt.Fprintln(out, c)
					} else {
						for i := 0; i < m/2; i++ {
							if i%2 == 0 {
								fmt.Fprint(out, r, " ")
							} else {
								fmt.Fprint(out, c, " ")
							}
						}
						fmt.Fprint(out, c)
						for i := 0; i < m/2; i++ {
							if i%2 == 0 {
								fmt.Fprint(out, " ", l)
							} else {
								fmt.Fprint(out, " ", c)
							}
						}
						fmt.Fprintln(out)
					}
				}
			}
		}
		out.Flush()
	}
}

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, m int
		Fscan(in, &n, &m)
		g := make([][]byte, n)
		for i := range g {
			Fscan(in, &g[i])
		}
		for i, r := range g {
			for j := i + 1; j < n; j++ {
				if r[j] == g[j][i] {
					Fprintln(out, "YES")
					for k := 0; k <= m; k++ {
						if k&1 == 0 {
							Fprint(out, i+1, " ")
						} else {
							Fprint(out, j+1, " ")
						}
					}
					Fprintln(out)
					return
				}
			}
		}
		if n < 3 {
			if m&1 == 0 {
				Fprintln(out, "NO")
				return
			}
			Fprintln(out, "YES")
			for i := 0; i < m; i += 2 {
				Fprint(out, 1, 2, " ")
			}
			Fprintln(out)
			return
		}
		Fprintln(out, "YES")
		if g[0][1] == g[1][2] && g[1][2] == g[2][0] {
			for i := 1; i <= m; i++ {
				Fprint(out, i%3, " ")
			}
			Fprintln(out)
			return
		}
		x := [3]int{}
		if g[0][1] == g[0][2] {
			x = [3]int{0, 1, 2}
			if g[1][2] != g[0][1] {
				x = [3]int{0, 2, 1}
			}
		} else if g[1][0] == g[1][2] {
			x = [3]int{1, 0, 2}
			if g[0][2] != g[1][0] {
				x = [3]int{1, 2, 0}
			}
		} else {
			x = [3]int{2, 0, 1}
			if g[0][1] != g[2][0] {
				x = [3]int{2, 1, 0}
			}
		}
		if m%2 > 0 {
			Fprint(out, x[0], " ")
			for i := 0; i < m-1; i += 2 {
				Fprint(out, x[1], x[0], " ")
			}
			Fprintln(out, x[1])
		} else if m%4 == 0 {
			Fprint(out, x[0], " ")
			for i := 0; i < m-2; i += 4 {
				Fprint(out, x[1], x[2], x[1], x[0], " ")
			}
			Fprintln(out, x[1], x[2])
		} else {
			Fprint(out, x[1], " ")
			for i := 0; i < m; i += 4 {
				Fprint(out, x[2], x[1], x[0], x[1], " ")
			}
			Fprintln(out)
		}
	}

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

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

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"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, m int
		Fscan(in, &n, &m)
		g := make([][]byte, n)
		for i := range g {
			Fscan(in, &g[i])
		}
		for i, r := range g {
			for j := i + 1; j < n; j++ {
				if r[j] == g[j][i] {
					Fprintln(out, "YES")
					for k := 0; k <= m; k++ {
						if k&1 == 0 {
							Fprint(out, i+1, " ")
						} else {
							Fprint(out, j+1, " ")
						}
					}
					Fprintln(out)
					return
				}
			}
		}
		if n < 3 {
			if m&1 == 0 {
				Fprintln(out, "NO")
				return
			}
			Fprintln(out, "YES")
			Fprint(out, 1, " ")
			for i := 0; i < m-1; i += 2 {
				Fprint(out, 2, 1)
			}
			Fprintln(out)
			return
		}
		Fprintln(out, "YES")
		if g[0][1] == g[1][2] && g[1][2] == g[2][0] {
			for i := 1; i <= m; i++ {
				Fprint(out, i%3, " ")
			}
			Fprintln(out)
			return
		}
		x := [3]int{}
		if g[0][1] == g[0][2] {
			x = [3]int{0, 1, 2}
			if g[1][2] != g[0][1] {
				x = [3]int{0, 2, 1}
			}
		} else if g[1][0] == g[1][2] {
			x = [3]int{1, 0, 2}
			if g[0][2] != g[1][0] {
				x = [3]int{1, 2, 0}
			}
		} else {
			x = [3]int{2, 0, 1}
			if g[0][1] != g[2][0] {
				x = [3]int{2, 1, 0}
			}
		}
		if m%2 > 0 {
			Fprint(out, x[0], " ")
			for i := 0; i < m-1; i += 2 {
				Fprint(out, x[1], x[0], " ")
			}
			Fprintln(out, x[1])
		} else if m%4 == 0 {
			Fprint(out, x[0], " ")
			for i := 0; i < m-2; i += 4 {
				Fprint(out, x[1], x[2], x[1], x[0], " ")
			}
			Fprintln(out, x[1], x[2])
		} else {
			Fprint(out, x[1], " ")
			for i := 0; i < m; i += 4 {
				Fprint(out, x[2], x[1], x[0], x[1], " ")
			}
			Fprintln(out)
		}
	}

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

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

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"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, m int
		Fscan(in, &n, &m)
		g := make([][]byte, n)
		for i := range g {
			Fscan(in, &g[i])
		}
		for i, r := range g {
			for j := i + 1; j < n; j++ {
				if r[j] == g[j][i] {
					Fprintln(out, "YES")
					for k := 0; k <= m; k++ {
						if k&1 == 0 {
							Fprint(out, i+1, " ")
						} else {
							Fprint(out, j+1, " ")
						}
					}
					Fprintln(out)
					return
				}
			}
		}
		if n < 3 {
			Fprintln(out, "NO")
			return
		}
		Fprintln(out, "YES")
		if g[0][1] == g[1][2] && g[1][2] == g[2][0] {
			for i := 1; i <= m; i++ {
				Fprint(out, i%3, " ")
			}
			Fprintln(out)
			return
		}
		x := [3]int{}
		if g[0][1] == g[0][2] {
			x = [3]int{0, 1, 2}
			if g[1][2] != g[0][1] {
				x = [3]int{0, 2, 1}
			}
		} else if g[1][0] == g[1][2] {
			x = [3]int{1, 0, 2}
			if g[0][2] != g[1][0] {
				x = [3]int{1, 2, 0}
			}
		} else {
			x = [3]int{2, 0, 1}
			if g[0][1] != g[2][0] {
				x = [3]int{2, 1, 0}
			}
		}
		if m%2 > 0 {
			Fprint(out, x[0], " ")
			for i := 0; i < m-1; i += 2 {
				Fprint(out, x[1], x[0], " ")
			}
			Fprintln(out, x[1])
		} else if m%4 == 0 {
			Fprint(out, x[0], " ")
			for i := 0; i < m-2; i += 4 {
				Fprint(out, x[1], x[2], x[1], x[0], " ")
			}
			Fprintln(out, x[1], x[2])
		} else {
			Fprint(out, x[1], " ")
			for i := 0; i < m; i += 4 {
				Fprint(out, x[2], x[1], x[0], x[1], " ")
			}
			Fprintln(out)
		}
	}

	var t int
	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"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n, m := readTwoNums(reader)
		G := make([][]byte, n)
		for i := 0; i < n; i++ {
			G[i], _ = reader.ReadBytes('\n')
		}
		res := solve(n, m, G)

		if len(res) == 0 {
			buf.WriteString("NO\n")
		} else {
			buf.WriteString("YES\n")
			for i := 0; i < len(res); i++ {
				buf.WriteString(fmt.Sprintf("%d ", res[i]))
			}
			buf.WriteByte('\n')
		}
	}
	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int, m int, G [][]byte) []int {
	res := make([]int, m+1)
	if m&1 == 1 {
		for i := 0; i < m; i++ {
			res[i] = 1
			res[i+1] = 2
		}
		res[m] = 1
		return res
	}
	// then m is even
	var ok bool
	var pivot [2]int

	has := make([][]int, n)
	for i := 0; i < n; i++ {
		has[i] = make([]int, 2)
		for j := 0; j < 2; j++ {
			has[i][j] = -1
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			if G[i][j] == G[j][i] {
				pivot = [...]int{i, j}
				ok = true
			}
			has[i][int(G[i][j]-'a')] = j
		}
	}

	if ok {
		for i := 0; i <= m; i++ {
			res[i] = pivot[i&1] + 1
		}
		return res
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			cur := has[j][int(G[i][j]-'a')]
			if cur < 0 {
				continue
			}
			if (m/2)&1 == 1 {
				for k := 0; k <= m; k++ {
					if k%4 == 0 {
						res[k] = i + 1
					} else if k%4 == 2 {
						res[k] = cur + 1
					} else {
						res[k] = j + 1
					}
				}
			} else {
				var p int
				res[p] = j + 1
				p++
				for k := 0; k < m/2; k++ {
					if k&1 == 1 {
						res[p] = j + 1
					} else {
						res[p] = cur + 1
					}
					p++
				}
				for k := 0; k < m/2; k++ {
					if k&1 == 1 {
						res[p] = j + 1
					} else {
						res[p] = i + 1
					}
					p++
				}
				return res
			}

			return res
		}
	}

	return nil
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n, m := readTwoNums(reader)
		G := make([][]byte, n)
		for i := 0; i < n; i++ {
			G[i], _ = reader.ReadBytes('\n')
		}
		res := solve(n, m, G)

		if len(res) == 0 {
			buf.WriteString("NO\n")
		} else {
			buf.WriteString("YES\n")
			for i := 0; i < len(res); i++ {
				buf.WriteString(fmt.Sprintf("%d ", res[i]))
			}
			buf.WriteByte('\n')
		}
	}
	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int, m int, G [][]byte) []int {
	var ok bool
	var pivot [2]int
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = -1
		b[i] = -1
	}
	for i := 0; i < n && !ok; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			if G[i][j] == G[j][i] {
				pivot = [...]int{i + 1, j + 1}
				ok = true
				break
			}
			if G[i][j] == 'a' && a[i] < 0 {
				a[i] = j
			}
			if G[i][j] == 'b' && b[i] < 0 {
				b[i] = j
			}
		}
	}
	res := make([]int, m+1)

	if ok {
		for i := 0; i < m; i += 2 {
			res[i] = pivot[0]
			res[i+1] = pivot[1]
		}
		if m&1 == 0 {
			res[m] = pivot[0]
		}
	} else {
		// all (u, v) != (v, u)
		if m&1 == 0 && n == 2 {
			return nil
		}
		if m&1 == 1 {
			// ababa
			for i := 0; i < m; i += 2 {
				res[i] = 1
				res[i+1] = 2
			}
			res[m] = 1
		} else {
			//aaabbaaa
			h := (m - 2) / 2
			res[0] = 0
			i := 1
			for i < h {
				res[i] = a[res[i-1]]
				i++
			}
			res[i] = b[res[i-1]]
			i++
			res[i] = b[res[i-1]]
			i++
			for i < m {
				res[i] = a[res[i-1]]
				i++
			}
			for j := 0; j < m; j++ {
				res[j]++
			}
		}
	}

	return res
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n, m int
	var s string
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &m)
		a := make([][]byte, n)
		for i := 0; i < n; i++ {
			a[i] = make([]byte, n)
			fmt.Fscan(in, &s)
			for j := range s {
				if i != j {
					a[i][j] = s[j]
				}
			}
		}
		if m%2 == 1 {
			fmt.Fprintln(out, "YES")
			fmt.Fprint(out, "1 2")
			for i := 1; i < m; i++ {
				if i%2 == 0 {
					fmt.Fprint(out, " 2")
				} else {
					fmt.Fprint(out, " 1")
				}
			}
			fmt.Fprintln(out)
		} else {
			if n == 2 {
				if a[0][1] != a[1][0] {
					fmt.Fprintln(out, "NO")
				} else {
					fmt.Fprintln(out, "YES")
					fmt.Fprint(out, "1 2")
					for i := 1; i < m; i++ {
						if i%2 == 0 {
							fmt.Fprint(out, " 2")
						} else {
							fmt.Fprint(out, " 1")
						}
					}
					fmt.Fprintln(out)
				}
			} else {
				fmt.Fprintln(out, "YES")
				if a[0][1] == a[1][2] && a[0][1] == a[2][0] {
					for i := 0; i <= m; i++ {
						fmt.Fprint(out, i%3+1, " ")
					}
					fmt.Fprintln(out)
				} else {
					c, l, r := 1, 2, 3
					if a[0][1] == a[1][2] {
						c, l, r = 2, 1, 3
					} else if a[1][2] == a[2][0] {
						c, l, r = 3, 1, 2
					}
					if m%4 == 0 {
						for i := 0; i < m/4; i++ {
							fmt.Fprintf(out, "%d %d %d %d ", c, l, c, r)
						}
						fmt.Fprintln(out, c)
					} else {
						for i := 0; i < m/2; i++ {
							if i%2 == 0 {
								fmt.Fprint(out, r, " ")
							} else {
								fmt.Fprint(out, c, " ")
							}
						}
						fmt.Fprint(out, c)
						for i := 0; i < m/2; i++ {
							if i%2 == 0 {
								fmt.Fprint(out, " ", l)
							} else {
								fmt.Fprint(out, " ", c)
							}
						}
						fmt.Fprintln(out)
					}
				}
			}
		}
		out.Flush()
	}
}


A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).Let $$$p$$$ be any permutation of length $$$n$$$. We define the fingerprint $$$F(p)$$$ of $$$p$$$ as the sorted array of sums of adjacent elements in $$$p$$$. More formally,$$$$$$F(p)=\mathrm{sort}([p_1+p_2,p_2+p_3,\ldots,p_{n-1}+p_n]).$$$$$$For example, if $$$n=4$$$ and $$$p=[1,4,2,3],$$$ then the fingerprint is given by $$$F(p)=\mathrm{sort}([1+4,4+2,2+3])=\mathrm{sort}([5,6,5])=[5,5,6]$$$.You are given a permutation $$$p$$$ of length $$$n$$$. Your task is to find a different permutation $$$p'$$$ with the same fingerprint. Two permutations $$$p$$$ and $$$p'$$$ are considered different if there is some index $$$i$$$ such that $$$p_i \ne p'_i$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 668$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2\le n\le 100$$$)  — the length of the permutation. The second line of each test case contains $$$n$$$ integers $$$p_1,\ldots,p_n$$$ ($$$1\le p_i\le n$$$). It is guaranteed that $$$p$$$ is a permutation.

For each test case, output $$$n$$$ integers $$$p'_1,\ldots, p'_n$$$ — a permutation such that $$$p'\ne p$$$ and $$$F(p')=F(p)$$$. We can prove that for every permutation satisfying the input constraints, a solution exists. If there are multiple solutions, you may output any.

package main

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

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

func max(a, b int) int {
	if a == min(a, b) {
		return b
	}
	return a
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func GetNum(p string) int64 {
	var ans int64 = 0
	flag := true
	i := 0
	n := len(p)
	if p[i] == '-' {
		flag = false
		i++
	}
	for ; i < n; i++ {
		ans = (ans << 1) + (ans << 3) + int64(p[i]-'0')
	}
	if !flag {
		ans = -ans
	}
	return ans
}
func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	return int(GetNum(intStr))
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func ReadInt64() int64 {
	int64Str := ReadString()
	return GetNum(int64Str)
}
func ReadInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

func init() {

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1<<10), int(2e+5))
	in.Split(bufio.ScanWords)

	out = make(chan string, 1<<4)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)
	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()
		for line := range out {
			write.WriteString(line + "\n")
		}
	}(writer)
}

func work() {
	n := ReadInt()
	p := ReadIntSlice(n)
	for i := n - 1; i >= 0; i-- {
		fmt.Printf("%d ", p[i])
	}
	fmt.Println()
}

func main() {

	for t := ReadInt(); t > 0; t-- {
		work()
	}
	close(out)
}

package main

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

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		aa := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &aa[j])
		}
		for j := n - 1; j >= 0; j-- {
			fmt.Printf("%d ", aa[j])
		}
		fmt.Println()
	}
}

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

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

	for t := in(); t > 0; t-- {
		n := in()
		a := make([]int, n)

		for i := range a {
			a[i] = in()
		}

		for i := n - 1; i >= 0; i-- {
			fmt.Print(a[i], " ")
		}

		fmt.Println()
	}
}

package main

import (
	"fmt"
)

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

	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		arr := [100]int{}
		for j := 0; j < n; j++ {
			fmt.Scan(&arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Printf("%d ", arr[j])
		}

		fmt.Printf("\n")
	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscan(in, &t)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Fprintf(out, "%d ", arr[j])

		}

		fmt.Fprintf(out, "\n")

	}

	defer out.Flush()
}

// kek

package main

import (
	"fmt"
)

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

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Scan(&n)
		for j := 0; j < n; j++ {
			fmt.Scan(&arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Printf("%d ", arr[j])
		}

		fmt.Printf("\n")
	}

}

//s

package main

import (
	"fmt"
)

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

	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		arr := [100]int{}
		for j := 0; j < n; j++ {
			fmt.Scan(&arr[j])
		}

		for j := 0; j < n/2; j++ {
			tmp := arr[j]
			arr[j] = arr[n-1-j]
			arr[n-1-j] = tmp
		}

		for j := 0; j < n; j++ {
			fmt.Printf("%d ", arr[j])
		}

		fmt.Printf("\n")
	}

}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	res := make([][]int, 0, t)

	for i := 0; i < t; i++ {
		var n, x int
		fmt.Scan(&n)
		arr := make([]int, 0, n)
		for j := 0; j < n; j++ {
			fmt.Scan(&x)
			arr = append(arr, x)
		}

		for j := 0; j < n/2; j++ {
			tmp := arr[j]
			arr[j] = arr[n-1-j]
			arr[n-1-j] = tmp
		}

		res = append(res, arr)
	}

	for i := 0; i < t; i++ {
		for _, v := range res[i] {
			fmt.Printf("%d ", v)
		}
		fmt.Printf("\n")
	}
}

//

package main

import (
	"fmt"
	// "sort"
	"strings"
)

func reverse(numbers []int) []int {
	for i := 0; i < len(numbers)/2; i++ {
		j := len(numbers) - i - 1
		numbers[i], numbers[j] = numbers[j], numbers[i]
	}
	return numbers
}

func main() {
	var t int
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		var l int
		fmt.Scan(&l)
		var arr []int = make([]int, l)
		for j := 0; j < l; j++ {
			fmt.Scan(&arr[j])
		}
		fmt.Println(strings.Trim(fmt.Sprint(reverse(arr)), "[]"))
	}
}

package main

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

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanInt := func(n *int) {
		scanner.Scan()
		num, _ := strconv.ParseInt(scanner.Text(), 10, 32)
		*n = int(num)
	}

	var t, n, p int
	scanInt(&t) // number of cases

	for i := 0; i < t; i++ {
		scanInt(&n)
		arrP := make([]string, n)

		for j := 1; j <= n; j++ {
			scanInt(&p)
			arrP[n-j] = fmt.Sprintf("%d", p)
		}

		fmt.Print(strings.Join(arrP, " ")+"\n")
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	// out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscanf(in, "%d\n", &n)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Printf("%d ", arr[j])
		}

		fmt.Printf("\n")
	}

}

//s

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)

	var t, n int
	fmt.Fscan(in, &n)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Printf("%d ", arr[j])
		}

		fmt.Printf("\n")
	}

}

//s

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscanf(in, "%d\n", &t)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &n)
		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d ", &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Fprintf(out, "%d ", arr[j])
			out.Flush()
		}

		fmt.Fprintf(out, "\n")
		out.Flush()
	}

}

//s

package main

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

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

	scanner := bufio.NewScanner(os.Stdin)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		scanner.Scan()
		n, _ = strconv.Atoi(scanner.Text())
		// fmt.Scan(&n)
		for j := 0; j < n; j++ {
			fmt.Scan(&arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Printf("%d ", arr[j])
		}

		fmt.Printf("\n")
	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscanf(in, "%d\n", &n)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &n)
		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d ", &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Fprintf(out, "%d ", arr[j])
		}

		fmt.Fprintf(out, "\n")
	}

	defer out.Flush()
}

//s

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscan(in, &n)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Fprintf(out, "%d ", arr[j])
		}

		fmt.Fprintf(out, "\n")
	}

}

//s

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscanf(in, "%d\n", &t)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &n)
		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d ", &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Fprintf(out, "%d ", arr[j])
		}

		fmt.Fprintf(out, "\n")
		out.Flush()
	}

}

//s

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	res := make([][]int, 0, t)

	for i := 0; i < t; i++ {
		var n, x int
		fmt.Scan(&n)
		arr := make([]int, 0, n)
		for j := 0; j < n; j++ {
			fmt.Scan(&x)
			arr = append(arr, x)
		}
		tmp := arr[0]
		arr[0] = arr[1]
		arr[1] = tmp
		res = append(res, arr)
	}

	for i := 0; i < t; i++ {
		for _, v := range res[i] {
			fmt.Printf("%d ", v)
		}
		fmt.Printf("\n")
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscanf(in, "%d\n", &n)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &n)
		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d", &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Fprintf(out, "%d ", arr[j])
		}

		fmt.Fprintf(out, "\n")
	}

}

//s

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscanf(in, "%d\n", &t)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &n)
		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d ", &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Fprintf(out, "%d ", arr[j])
		}

		fmt.Fprintf(out, "\n")
	}

	out.Flush()
}

//s

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscanf(in, "%d\n", &n)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &n)
		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d ", &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Fprintf(out, "%d ", arr[j])
		}

		fmt.Fprintf(out, "\n")
	}

	out.Flush()
}

//s

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	// out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscanf(in, "%d\n", &n)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &n)
		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d", &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Printf("%d ", arr[j])
		}

		fmt.Printf("\n")
	}

}

//s

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var t, n int
	fmt.Fscanf(in, "%d\n", &n)

	arr := [100]int{}
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &n)
		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d ", &arr[j])
		}

		for j := n - 1; j >= 0; j-- {
			fmt.Fprintf(out, "%d ", arr[j])
		}

		fmt.Fprintf(out, "\n")
	}
}

//s

package main

import (
	"fmt"
	"strings"
)

// 3
// 2
// 1 2
// 6
// 2 1 6 5 4 3
// 5
// 2 4 3 1 5
func main() {
	var t int
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		var l int
		fmt.Scan(&l)
		var arr []int = make([]int, l)
		for j := 0; j < l; j++ {
			fmt.Scan(&arr[j])
		}
		if l%2 == 0 {
			for j := 0; j < l-1; j++ {
				temp := arr[j]
				arr[j] = arr[j+1]
				arr[j+1] = temp
			}
		} else {
			for j := 0; j <= l-3; j++ {
				temp := arr[j]
				arr[j] = arr[j+2]
				arr[j+2] = temp
			}
		}
		fmt.Println(strings.Trim(fmt.Sprint(arr), "[]"))
	}
}

// 2 4 3 1 5
// 0 1 2 3 4
//     i

// 3 1 5 4 2

package main

import (
	"fmt"
	"strings"
)

// 3
// 2
// 1 2
// 6
// 2 1 6 5 4 3
// 5
// 2 4 3 1 5
func main() {
	var t int
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		var l int
		fmt.Scan(&l)
		var arr []int = make([]int, l)
		for j := 0; j < l; j++ {
			fmt.Scan(&arr[j])
		}
		if l%2 == 0 {
			for j := 0; j <= l-2; j = j + 2 {
				temp := arr[j]
				arr[j] = arr[j+1]
				arr[j+1] = temp
			}
		} else {
			for j := 0; j <= l-3; j++ {
				temp := arr[j]
				arr[j] = arr[j+2]
				arr[j+2] = temp
			}
			temp := arr[l-1]
			arr[l-1] = arr[l-2]
			arr[l-2] = temp
		}
		fmt.Println(strings.Trim(fmt.Sprint(arr), "[]"))
	}
}

// 2 4 3 1 5

// 3 1 5 2 4


Farmer John has a farm that consists of $$$n$$$ pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could have negative weight, where the cows go so fast that they go back in time! However, Farmer John guarantees that it is impossible for the cows to get stuck in a time loop, where they can infinitely go back in time by traveling across a sequence of roads. Also, each pair of pastures is connected by at most one road in each direction.Unfortunately, Farmer John lost the map of the farm. All he remembers is an array $$$d$$$, where $$$d_i$$$ is the smallest amount of time it took the cows to reach the $$$i$$$-th pasture from pasture $$$1$$$ using a sequence of roads. The cost of his farm is the sum of the weights of each of the roads, and Farmer John needs to know the minimal cost of a farm that is consistent with his memory.

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of pastures. The second line of each test case contains $$$n$$$ space separated integers $$$d_1, d_2, \ldots, d_n$$$ ($$$0 \leq d_i \leq 10^9$$$) — the array $$$d$$$. It is guaranteed that $$$d_1 = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, output the minimum possible cost of a farm that is consistent with Farmer John's memory.

NoteIn the first test case, you can add roads   from pasture $$$1$$$ to pasture $$$2$$$ with a time of $$$2$$$,  from pasture $$$2$$$ to pasture $$$3$$$ with a time of $$$1$$$,  from pasture $$$3$$$ to pasture $$$1$$$ with a time of $$$-3$$$,  from pasture $$$3$$$ to pasture $$$2$$$ with a time of $$$-1$$$,  from pasture $$$2$$$ to pasture $$$1$$$ with a time of $$$-2$$$.  The total cost is $$$2 + 1 + -3 + -1 + -2 = -3$$$.In the second test case, you can add a road from pasture $$$1$$$ to pasture $$$2$$$ with cost $$$1000000000$$$ and a road from pasture $$$2$$$ to pasture $$$1$$$ with cost $$$-1000000000$$$. The total cost is $$$1000000000 + -1000000000 = 0$$$.In the third test case, you can't add any roads. The total cost is $$$0$$$.

package main

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

var input io.Reader = bufio.NewReader(os.Stdin)

//fmt.Fscan(input,&x)
//fmt.Println(x)
func main() {
	var T int
	fmt.Fscan(input, &T)
	for {
		var n int
		fmt.Fscan(input, &n)
		v := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(input, &v[i])
		}
		sort.Ints(v[1:n+1])
		var ans int64 = 0
		sum := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			sum[i] = sum[i-1] + int64(v[i])
			var tt int64 = int64(i)*int64(v[i]) - sum[i]
			ans += tt
		}
		fmt.Println(int64(v[n]) - ans)
		T--
		if T == 0 {
			break
		}
	}
}

package main

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

func CF1540A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t int
	var n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		arr := make([]int64, n)
		for i := range arr {
			Fscan(in, &arr[i])
		}
		if n < 3 {
			Fprintln(out, 0)
			continue
		}
		sort.Slice(arr, func(i, j int) bool {
			return arr[i] < arr[j]
		})
		// sort.Ints(arr)
		var ans int64
		it := arr[2]
		ans = it
		c := int64(1)
		for i := 3; i < n; i++ {
			it = (arr[i]-arr[i-1])*c + it + arr[i] - arr[i-2]
			ans += it
			c++
		}
		Fprintln(out, -ans)

	}
}

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

package main

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

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

	var T, n int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		d := make([]int, n)
		for i := range d {
			Fscan(in, &d[i])
		}
		sort.Ints(d)
		ans := int64(0)
		for i := int64(1); i < n; i++ {
			ans += int64(d[i]-d[i-1]) * (1 - i*(n-i))
		}
		Fprintln(out, ans)
	}
}

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

package main

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

type ll []int64

func (a ll) Len() int           { return len(a) }
func (a ll) Less(i, j int) bool { return a[i]< a[j] }
func (a ll) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	r := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(r, &t)

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

		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		ans := solve(a, n)
		fmt.Println(ans)
	}
}

func solve(d []int, n int) int64 {
	if n == 1 {
		return 0
	}

	sort.Ints(d)

	var cost int64

	cost = int64(d[len(d) - 1])

	k := 0
	dp := make([]int64, n)
	dp[0] = 0

	for i := 1; i < n; i++ {
		diff := d[i] - d[i - 1] // 2
		dp[i] = - int64(k) * int64(diff) + dp[i - 1] - int64(diff)
		k++

		cost += dp[i]
	}

	return cost

}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n int
		_, _ = fmt.Fscan(in, &n)

		d := make([]int64, n)
		for i := 0; i < n; i++ {
			_, _ = fmt.Fscan(in, &d[i])
		}

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

		var ans int64
		for i := 1; i < n; i++ {
			ans -= (d[i] - d[i-1]) * (int64(i)*int64(n-i) - 1)
		}

		fmt.Println(ans)
	}
}

package main

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

var input io.Reader = bufio.NewReader(os.Stdin)

//fmt.Fscan(input,&x)
//fmt.Println(x)
func main() {
	var T int
	fmt.Fscan(input, &T)
	for {
		var n int
		fmt.Fscan(input, &n)
		v := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(input, &v[i])
		}
		V := v[1 : n+1]
		sort.Slice(V, func(i int, j int) bool {
			return i < j
		})
		var ans int64
		sum := make([]int, n+1)
		for i := 1; i <= n; i++ {
			sum[i] = sum[i-1] + v[i]
			ans += int64(i*v[i] - sum[i])
		}
		fmt.Println(int64(v[n]) - ans)
		T--
		if T == 0 {
			break
		}
	}
}


You are given an integer $$$n$$$.You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times:   Replace $$$n$$$ with $$$\frac{n}{2}$$$ if $$$n$$$ is divisible by $$$2$$$;  Replace $$$n$$$ with $$$\frac{2n}{3}$$$ if $$$n$$$ is divisible by $$$3$$$;  Replace $$$n$$$ with $$$\frac{4n}{5}$$$ if $$$n$$$ is divisible by $$$5$$$. For example, you can replace $$$30$$$ with $$$15$$$ using the first operation, with $$$20$$$ using the second operation or with $$$24$$$ using the third operation.Your task is to find the minimum number of moves required to obtain $$$1$$$ from $$$n$$$ or say that it is impossible to do it.You have to answer $$$q$$$ independent queries.

The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. The next $$$q$$$ lines contain the queries. For each query you are given the integer number $$$n$$$ ($$$1 \le n \le 10^{18}$$$).

Print the answer for each query on a new line. If it is impossible to obtain $$$1$$$ from $$$n$$$, print -1. Otherwise, print the minimum number of moves required to do it.

package main

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

func main() {
	var t int
	var n int64
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		count := 0
		for {
			if n == 1 {
				break
			} else if n%2 == 0 {
				n = n / 2
			} else if n%3 == 0 {
				n = 2 * n / 3
			} else if n%5 == 0 {
				n = 4 * n / 5
			} else {
				break
			}
			count++
		}
		if n == 1 {
			fmt.Println(count)
		} else {
			fmt.Println(-1)
		}
	}
}

package main

import "fmt"

func main(){
    var q,c int
    var n int64
    fmt.Scanln(&q)
    for i := 1;i <= q;i ++{
        fmt.Scanln(&n)
        c = 0
        for n != 1{
            if n % 2 == 0{
	        n = n / 2
	    }else if n % 3 == 0{
		n = n / 3 * 2
	    }else if n % 5 == 0{
		n = n / 5 * 4
	    }else{
	    	break
            }
	    c ++
	}
        if n == 1{
	    fmt.Println(c)
	}else{
	    fmt.Println(-1)
	}
    }
}

package main

import "fmt"

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

	for i := 0; i < q; i++ {
		var n uint64
		fmt.Scan(&n)

		s := 0
		for n % 2 == 0 {
			n /= 2
			s += 1
		}
		for n % 3 == 0 {
			n /= 3
			s += 2
		}
		for n % 5 == 0 {
			n /= 5
			s += 3
		}

		if n > 1 {
			s = -1
		}

		fmt.Println(s)
	}
}

package main

import "fmt"

//http://codeforces.com/contest/1176/problem/A
func main() {

	var q int
	fmt.Scanf("%d", &q)

	for i := 0; i < q; i++ {
		var n int64
		var ans = 0
		fmt.Scan(&n)
		for {
			if n <= 1 {
				break
			}
			if n%2 == 0 {
				n /= 2
			} else if n%3 == 0 {
				n = (2 * n) / 3
			} else if n%5 == 0 {
				n = (4 * n) / 5
			} else {
				ans = -1
				break
			}
			ans++
		}
		fmt.Println(ans)
	}

	//fmt.Println(q)
}

package main

import (
    "fmt"
)

func main() {
    var q int
    fmt.Scanf("%d", &q)
    for i := 0; i < q; i++ {
        var n int64
        var ans = 0
        fmt.Scan(&n)
        for {
            if n <= 1 {
                break
            }
            if n % 2 == 0 {
                n /= 2
            } else if n % 3 == 0 {
                n = (2 * n) / 3
            } else if n % 5 == 0 {
                n = (4 * n) / 5
            } else {
                ans = -1
                break
            }
            ans++
        }
        fmt.Println(ans)
    }
}

package main

import (
	"fmt"
)

func main() {
	var t, n uint64
	fmt.Scan(&t)
	for t != 0 {
		fmt.Scan(&n)
		moves := 0
		for n != 1 {
			if n%2 == 0 {
				n = n / 2
			} else if n%3 == 0 {
				n = (2 * n) / 3
			} else if n%5 == 0 {
				n = (4 * n) / 5
			} else {
				break
			}
			moves++
		}
		if n != 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(moves)
		}
		t--
	}
}

// 30
// Replace n with n/2 if n is divisible by 2;
// Replace n with 2n/3 if n is divisible by 3;
// Replace n with 4n/5 if n is divisible by 5.
// if 2 then 15
// if 3 then 30*2/3 = 20
// if 5 4*30/5 = 24

package main

import "fmt"

func main() {
    var q int
    var n int64
    fmt.Scanln(&q)
    for i := 0; i < q; i ++ {
        fmt.Scanln(&n)
        if n <= 1 {
            fmt.Println(0)
        } else {
            cnt := 0
            for n > 1 {
                if n % 2 == 0 {
                    n = n / 2
                    cnt ++
                } else if n % 3 == 0 {
                    n /= 3
                    cnt += 2
                } else if n % 5 == 0 {
                    n /= 5
                    cnt += 3
                } else {
                    cnt = -1
                    break
                }
            }
            fmt.Println(cnt)
        }
    }
}

package main

import "fmt"

func main(){
	var q int
	fmt.Scanln(&q)
	for i:= 0;i < q ; i++ {
		var n, ans int64 = 0, 0
		fmt.Scanln(&n)
		for ; n%5 ==0; n/=5{
			ans += 3
		}
		for ; n%3 ==0; n/=3{
			ans += 2
		}
		for ; n%2 ==0; n/=2{
			ans += 1
		}
		if n ==1 {
			fmt.Println(ans)
		} else{
			fmt.Println("-1")
		}
	}
}

package main

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

import "strconv"

func normaliseBy235(numberRaw string) (moves int) {
	number, err := strconv.ParseInt(numberRaw, 10, 64)
	if err != nil {
		moves = -1
		return
	}

	if number%7 == 0 {
		moves = -1
		return
	}

	if number == 1 {
		moves = 0
		return
	}

	for number%2 == 0 {
		number /= 2
		moves++
	}

	for number%5 == 0 {
		number /= 5
		moves += 3
	}

	for number%3 == 0 {
		number /= 3
		moves += 2
	}

	if number != 1 {
		moves = -1
	}

	return
}

func main() {

	var rawExpected string
	var expected int
	var err error

	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {

		if len(rawExpected) == 0 {
			rawExpected = scanner.Text()
			expected, err = strconv.Atoi(rawExpected)
			if err != nil {
				panic(err)
			}
			continue
		}

		fmt.Println(normaliseBy235(scanner.Text()))
		expected--

		if expected == 0 {
			break
		}
	}
}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/1176/A

package main

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

func _Solve(n int64, twos int, threes int, fives int) int {
	if n == 1 {
		return twos + 2*threes + 3*fives
	} else if n%2 == 0 {
		return _Solve(n/2, twos+1, threes, fives)
	} else if n%3 == 0 {
		return _Solve(n/3, twos, threes+1, fives)
	} else if n%5 == 0 {
		return _Solve(n/5, twos, threes, fives+1)
	}
	return -1
}

func Solve(n int64) int {
	return _Solve(n, 0, 0, 0)
}

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

	var q int
	var n int64

	fmt.Fscanf(reader, "%d\n", &q)
	for i := 0; i < q; i++ {
		fmt.Fscanf(reader, "%d\n", &n)
		fmt.Fprintf(writer, "%d\n", Solve(n))
	}
}

package main

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

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		count := 0
		for {
			if n == 1 {
				break
			} else if n%2 == 0 {
				n = n / 2
			} else if n%3 == 0 {
				n = 2 * n / 3
			} else if n%5 == 0 {
				n = 4 * n / 5
			} else {
				break
			}
			count++
		}
		if n == 1 {
			fmt.Println(count)
		} else {
			fmt.Println(-1)
		}
	}
}

package main

import "fmt"

func main(){
    var q,n,c int
    fmt.Scanln(&q)
    for i := 1;i <= q;i ++{
        fmt.Scanln(&n)
        c = 0
        for n != 1{
            if n % 2 == 0{
	        n = n / 2
	    }else if n % 3 == 0{
		n = n / 3 * 2
	    }else if n % 5 == 0{
		n = n / 5 * 4
	    }else{
	    	break
            }
	    c ++
	}
        if n == 1{
	    fmt.Println(c)
	}else{
	    fmt.Println(-1)
	}
    }
}

package main

import (
	"fmt"
)

func main() {
	var t, n int
	fmt.Scan(&t)
	for t != 0 {
		fmt.Scan(&n)
		moves := 0
		for n != 1 {
			if n%2 == 0 {
				n = n / 2
			} else if n%3 == 0 {
				n = (2 * n) / 3
			} else if n%5 == 0 {
				n = (4 * n) / 5
			} else {
				break
			}
			moves++
		}
		if n != 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(moves)
		}
		t--
	}
}

// 30

// Replace n with n/2 if n is divisible by 2;
// Replace n with 2n/3 if n is divisible by 3;
// Replace n with 4n/5 if n is divisible by 5.

// if 2 then 15
// if 3 then 30*2/3 = 20
// if 5 4*30/5 = 24

package main

import "fmt"

func main() {
    var q int
    var n int
    fmt.Scanln(&q)
    for i := 0; i < q; i ++ {
        fmt.Scanln(&n)
        if n <= 1 {
            fmt.Println(0)
        } else {
            cnt := 0
            for n > 1 {
                if n % 2 == 0{
                    n = n / 2
                    cnt ++
                } else if n % 3 == 0 {
                    n /= 3
                    cnt += 2
                } else if n % 5 == 0 {
                    n /= 5
                    cnt += 3
                } else {
                    cnt = -1
                    break
                }
            }
            fmt.Println(cnt)
        }

    }

}

package main

import "fmt"

func main() {
    var q int
    var n int
    fmt.Scanln(&q)
    for i := 0; i < q; i ++ {
        fmt.Scanln(&n)
        if n <= 1 {
            fmt.Println(1)
        } else {
            cnt := 0
            for n > 1 {
                if n % 2 == 0{
                    n = n / 2
                    cnt ++
                } else if n % 3 == 0 {
                    n /= 3
                    cnt += 2
                } else if n % 5 == 0 {
                    n /= 5
                    cnt += 3
                } else {
                    cnt = -1
                    break
                }
            }
            fmt.Println(cnt)
        }

    }

}

package main

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

func minDivisionFor235(n int) int {
	var moves int
	if n == 1 {
		return moves
	}

	for {
		if n%7 == 0 {
			return -1
		}

		if n%2 == 0 {
			n = n / 2
			moves++
		}

		if n%3 == 0 {
			n = (2 * n) / 3
			moves++
		}

		if n%5 == 0 {
			n = (4 * n) / 5
			moves++
		}

		if n == 1 {
			break
		}
	}

	return moves
}

func main() {

	var firstWord string
	var maxTimes, currTime int
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		if err := scanner.Err(); err != nil {
			panic(err)
		}

		if firstWord == "" {
			firstWord = scanner.Text()
			maxTimes, _ = strconv.Atoi(firstWord)
			continue
		}

		if currTime > maxTimes-1 {
			continue
		}

		secondWord := scanner.Text()
		currTime++
		number, err := strconv.Atoi(secondWord)
		if err != nil {
			fmt.Println("-1")
			continue
		}

		fmt.Println(strconv.Itoa(minDivisionFor235(number)))
	}
}

package main

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

func minDivisionFor235(n int) int {
	var moves int
	if n == 1 {
		return moves
	}

	for {
		if n%7 == 0 {
			return -1
		}

		if n%2 == 0 {
			n = n / 2
			moves++
		}

		if n%3 == 0 {
			n = (2 * n) / 3
			moves++
		}

		if n%5 == 0 {
			n = (4 * n) / 5
			moves++
		}

		if n == 1 {
			break
		}
	}

	return moves
}

func main() {

	var firstWord string
	// var maxTimes, currTime int
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		if err := scanner.Err(); err != nil {
			panic(err)
		}

		if firstWord == "" {
			firstWord = scanner.Text()
			// maxTimes, _ = strconv.Atoi(firstWord)
			continue
		}

		// if currTime > maxTimes-1 {
		// 	break
		// }

		secondWord := scanner.Text()
		// currTime++
		number, err := strconv.Atoi(secondWord)
		if err != nil {
			fmt.Println("-1")
			continue
		}

		fmt.Println(strconv.Itoa(minDivisionFor235(number)))
	}
}

package main

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

func minDivisionFor235(n int) int {
	var moves int
	if n == 1 {
		return moves
	}

	for {
		if n%7 == 0 {
			return -1
		}

		if n%2 == 0 {
			n = n / 2
			moves++
		}

		if n%3 == 0 {
			n = (2 * n) / 3
			moves++
		}

		if n%5 == 0 {
			n = (4 * n) / 5
			moves++
		}

		if n == 1 {
			break
		}
	}

	return moves
}

func main() {

	var firstWord string
	var maxTimes, currTime int
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		if err := scanner.Err(); err != nil {
			panic(err)
		}

		if firstWord == "" {
			firstWord = scanner.Text()
			maxTimes, _ = strconv.Atoi(firstWord)
			continue
		}

		if currTime > maxTimes-1 {
			break
		}

		secondWord := scanner.Text()
		currTime++
		number, err := strconv.Atoi(secondWord)
		if err != nil {
			continue
		}

		fmt.Println(minDivisionFor235(number))
	}
}

package main

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

func minDivisionFor235(n int) int {
	var moves int
	if n == 1 {
		return moves
	}

	for {
		if n%7 == 0 {
			return -1
		}

		if n%2 == 0 {
			n = n / 2
			moves++
		}

		if n%3 == 0 {
			n = (2 * n) / 3
			moves++
		}

		if n%5 == 0 {
			n = (4 * n) / 5
			moves++
		}

		if n == 1 {
			break
		}
	}

	return moves
}

func main() {

	var firstWord string
	// var maxTimes, currTime int
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		if err := scanner.Err(); err != nil {
			panic(err)
		}

		if firstWord == "" {
			firstWord = scanner.Text()
			// maxTimes, _ = strconv.Atoi(firstWord)
			continue
		}

		// if currTime > maxTimes-1 {
		// 	break
		// }

		secondWord := scanner.Text()
		// currTime++
		number, err := strconv.Atoi(secondWord)
		if err != nil {
			// fmt.Println("-1")
			continue
		}

		fmt.Println(strconv.Itoa(minDivisionFor235(number)))
	}
}

package main

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

func minDivisionFor235(n int) int {
	var moves int
	if n == 1 {
		return moves
	}

	for {
		if n%7 == 0 {
			return -1
		}

		if n%2 == 0 {
			n = n / 2
			moves++
		}

		if n%3 == 0 {
			n = (2 * n) / 3
			moves++
		}

		if n%5 == 0 {
			n = (4 * n) / 5
			moves++
		}

		if n == 1 {
			break
		}
	}

	return moves
}

func main() {

	var firstWord string
	var maxTimes, currTime int
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		if err := scanner.Err(); err != nil {
			panic(err)
		}

		if firstWord == "" {
			firstWord = scanner.Text()
			maxTimes, _ = strconv.Atoi(firstWord)
			continue
		}

		if currTime > maxTimes-1 {
			break
		}

		secondWord := scanner.Text()
		currTime++
		number, err := strconv.Atoi(secondWord)
		if err != nil {
			fmt.Println("-1")
			continue
		}

		fmt.Println(strconv.Itoa(minDivisionFor235(number)))
	}
}

package main

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

func minDivisionFor235(n int) int {
	var moves int
	if n == 1 {
		return moves
	}

	for {
		if n%7 == 0 {
			return -1
		}

		if n%2 == 0 {
			n = n / 2
			moves++
		}

		if n%3 == 0 {
			n = (2 * n) / 3
			moves++
		}

		if n%5 == 0 {
			n = (4 * n) / 5
			moves++
		}

		if n == 1 {
			break
		}
	}

	return moves
}

func main() {

	var firstWord string
	// var maxTimes, currTime int
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		if err := scanner.Err(); err != nil {
			panic(err)
		}

		if firstWord == "" {
			firstWord = scanner.Text()
			// maxTimes, _ = strconv.Atoi(firstWord)
			continue
		}

		// if currTime > maxTimes-1 {
		// 	break
		// }

		secondWord := scanner.Text()
		// currTime++
		number, err := strconv.Atoi(secondWord)
		if err != nil {
			fmt.Println("-1")
			continue
		}

		fmt.Println(minDivisionFor235(number))
	}
}

package main

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

func minDivisionFor235(n int) int {
	var moves int
	if n == 1 {
		return moves
	}

	for {
		if n%7 == 0 {
			return -1
		}

		if n%2 == 0 {
			n = n / 2
			moves++
		}

		if n%3 == 0 {
			n = (2 * n) / 3
			moves++
		}

		if n%5 == 0 {
			n = (4 * n) / 5
			moves++
		}

		if n == 1 {
			break
		}
	}

	return moves
}

func main() {

	var firstWord string
	var maxTimes, currTime int
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		if err := scanner.Err(); err != nil {
			panic(err)
		}

		if firstWord == "" {
			firstWord = scanner.Text()
			maxTimes, _ = strconv.Atoi(firstWord)
			continue
		}

		if currTime > maxTimes-1 {
			break
		}

		secondWord := scanner.Text()
		currTime++
		number, err := strconv.Atoi(secondWord)
		if err != nil {
			fmt.Println("-1")
			continue
		}

		fmt.Println(minDivisionFor235(number))
	}
}


You are given an integer array $$$a$$$ of length $$$n$$$. Does there exist an array $$$b$$$ consisting of $$$n+1$$$ positive integers such that $$$a_i=\gcd (b_i,b_{i+1})$$$ for all $$$i$$$ ($$$1 \leq i \leq n$$$)? Note that $$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 10^5$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ space-separated integers $$$a_1,a_2,\ldots,a_n$$$ representing the array $$$a$$$ ($$$1 \leq a_i \leq 10^4$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, output "YES" if such $$$b$$$ exists, otherwise output "NO". You can print each letter in any case (upper or lower).

NoteIn the first test case, we can take $$$b=[343,343]$$$.In the second test case, one possibility for $$$b$$$ is $$$b=[12,8,6]$$$.In the third test case, it can be proved that there does not exist any array $$$b$$$ that fulfills all the conditions.

package main

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

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

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

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

		aa := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}

		f := true
		for i := 1; i < n-1; i++ {
			if aa[i]%gcd(aa[i-1], aa[i+1]) > 0 {
				f = false
				break
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

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

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

		aa := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}
		bb := make([]int64, n+1)
		bb[0] = aa[0]
		bb[n] = aa[n-1]
		for i := 1; i < n; i++ {
			bb[i] = lcm(aa[i-1], aa[i])
		}

		f := true
		for i := 0; i < n; i++ {
			if aa[i] != gcd(bb[i], bb[i+1]) {
				f = false
				break
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func solve(_r io.Reader, _w io.Writer) {

	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)

	defer out.Flush()

	var n, T int
	Fscan(in, &T)
	for ; T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
		}
		flag := true
		num := a[1]
		for i := 2; i <= n; i++ {
			x := lcm(a[i], a[i - 1])
			if gcd(num, x) != a[i - 1] {
			    flag = false
			    break
			}
			num = x
		}
		if flag {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}

}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
    return x / gcd(x, y) * y;
}

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

package main

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

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

func b1736(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var n int
	var x int

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

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)

		for i := 0; i < n; i++ {
			Fscan(in, &x)
			a[i] = x
		}

		ans := "YES"
		for i := 1; i < n-1; i++ {
			if gcd(a[i-1]/gcd(a[i-1], a[i]), a[i+1]/gcd(a[i+1], a[i])) != 1 {
				ans = "NO"
				break
			}
		}

		Fprintln(out, ans)
	}
}

package main

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

func gcd(a, b int) int {
	if b == 0 { return a }
	return gcd(b, a % b)
}

func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

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

		b := make([]int, n + 1)
		b[0] = a[0]
		cant := false

		for i := range a {
			if i != n - 1 {
				b[i + 1] = lcm(a[i], a[i+1])
			} else {
				b[i + 1] = a[i]
			}
			if gcd(b[i+1], b[i]) != a[i] {
				cant = true
				break
			}
		}

		if cant {
			fmt.Fprintln(w, "NO")
		} else {
			fmt.Fprintln(w, "YES")
		}
	}

}

package main

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

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	scanner := bufio.NewScanner(os.Stdin)
	// mod := int64(998244353998244353)
	for i := 0; i < t; i++ {
		var s string
		if scanner.Scan() {
			scanner.Text() // ignore n
		}
		var tempArr []string
		if scanner.Scan() {
			s = scanner.Text()
			tempArr = strings.Split(s, " ")
		}
		var arr []int
		for _, v := range tempArr {
			temp, _ := strconv.Atoi(v)
			arr = append(arr, temp)
		}

		var possible bool = true
		var lcms []int
		for i := 0; i < len(arr)-1; i++ {
			lcm := LCM(arr[i], arr[i+1])
			lcms = append(lcms, lcm)
			if i >= 1 {
				if GCD(lcms[i-1], lcms[i]) != arr[i] {
					possible = false
					break
				}
			}
		}
		if possible {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

// greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a * b / GCD(a, b)

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

package main

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

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

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

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

		aa := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}
		f := true
		for i := 0; i < n-2; i++ {
			if gcd(aa[i], aa[i+2]) > gcd(aa[i], aa[i+1]) {
				f = false
				break
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

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

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

		aa := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}
		if n <= 2 {
			fmt.Fprintln(out, "YES")
			continue
		}

		f := true
		for i := 1; i < n-1; i++ {
			d := lcm(aa[i], aa[i+1])
			if d > aa[i] {
				f = false
				break
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func solve(_r io.Reader, _w io.Writer) {

	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)

	defer out.Flush()

	var n, T int
	Fscan(in, &T)
	for ; T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
		}
		flag := true
		num := a[1]
		for i := 2; i <= n; i++ {
			x := lcm(a[i], num)
			if x <= 0 || gcd(num, x) != a[i - 1] {
			    flag = false
			    break
			}
			num = x
		}
		if flag {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}

}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
    return x / gcd(x, y) * y;
}

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

package main

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

func solve(_r io.Reader, _w io.Writer) {

	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)

	defer out.Flush()

	var n, T int
	Fscan(in, &T)
	for ; T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
		}
		flag := true
		num := a[1]
		for i := 2; i <= n; i++ {
			x := lcm(a[i], num)
			if gcd(num, x) != a[i - 1] {
			    flag = false
			    break
			}
		}
		if flag {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}

}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
    return x / gcd(x, y) * y;
}

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

package main

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

func solve(_r io.Reader, _w io.Writer) {

	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)

	defer out.Flush()

	var n, T int
	Fscan(in, &T)
	for ; T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
		}
		flag := true
		num := a[1]
		for i := 2; i <= n; i++ {
			x := a[i] / gcd(a[i], num)
			y := a[i-1] / num
			if gcd(x, y) != 1 {
				flag = false
				break
			}
			if num % a[i - 1] == 0 && num > a[i - 1] {
			    flag = false
			    break
			}
			num = num * x
		}
		if flag {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}

}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

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

package main

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

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

func b1736(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var n int
	var x int

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

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)

		for i := 0; i < n; i++ {
			Fscan(in, &x)
			a[i] = x
		}

		ans := "YES"
		for i := 1; i < n-1; i++ {
			if gcd(a[i-1], a[i+1]) != 1 {
				ans = "NO"
				break
			}
		}

		Fprintln(out, ans)
	}
}


There are two rival donut shops.The first shop sells donuts at retail: each donut costs $$$a$$$ dollars.The second shop sells donuts only in bulk: box of $$$b$$$ donuts costs $$$c$$$ dollars. So if you want to buy $$$x$$$ donuts from this shop, then you have to buy the smallest number of boxes such that the total number of donuts in them is greater or equal to $$$x$$$.You want to determine two positive integer values:   how many donuts can you buy so that they are strictly cheaper in the first shop than in the second shop?  how many donuts can you buy so that they are strictly cheaper in the second shop than in the first shop? If any of these values doesn't exist then that value should be equal to $$$-1$$$. If there are multiple possible answers, then print any of them.The printed values should be less or equal to $$$10^9$$$. It can be shown that under the given constraints such values always exist if any values exist at all.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Each of the next $$$t$$$ lines contains three integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$1 \le a \le 10^9$$$, $$$2 \le b \le 10^9$$$, $$$1 \le c \le 10^9$$$).

For each testcase print two positive integers. For both shops print such $$$x$$$ that buying $$$x$$$ donuts in this shop is strictly cheaper than buying $$$x$$$ donuts in the other shop. $$$x$$$ should be greater than $$$0$$$ and less or equal to $$$10^9$$$. If there is no such $$$x$$$, then print $$$-1$$$. If there are multiple answers, then print any of them.

NoteIn the first testcase buying any number of donuts will be cheaper in the second shop. For example, for $$$3$$$ or $$$5$$$ donuts you'll have to buy a box of $$$10$$$ donuts for $$$4$$$ dollars. $$$3$$$ or $$$5$$$ donuts in the first shop would cost you $$$15$$$ or $$$25$$$ dollars, respectively, however. For $$$20$$$ donuts you'll have to buy two boxes for $$$8$$$ dollars total. Note that $$$3$$$ and $$$5$$$ are also valid answers for the second shop, along with many other answers.In the second testcase buying any number of donuts will be either cheaper in the first shop or the same price. $$$8$$$ donuts cost $$$32$$$ dollars in the first shop and $$$40$$$ dollars in the second shop (because you have to buy two boxes). $$$10$$$ donuts will cost $$$40$$$ dollars in both shops, so $$$10$$$ is not a valid answer for any of the shops.In the third testcase $$$1$$$ donut costs $$$2$$$ and $$$3$$$ dollars, respectively. $$$2$$$ donuts cost $$$4$$$ and $$$3$$$ dollars. Thus, $$$1$$$ is a valid answer for the first shop and $$$2$$$ is a valid answer for the second shop.In the fourth testcase $$$10^9$$$ donuts cost $$$10^{18}$$$ dollars in the first shop and $$$10^9$$$ dollars in the second shop.

package main

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

var reader *bufio.Reader

func parseInt(s string) int {
	return int(parseInt64(s))
}

func parseInt64(s string) int64 {
	x, _ := strconv.ParseInt(s, 10, 64)
	return x
}

func readLine() string {
	if reader == nil {
		reader = bufio.NewReader(os.Stdin)
	}
	s, _ := reader.ReadString('\n')
	return strings.TrimSuffix(s, "\n")
}

func readFields() []string {
	return strings.Fields(readLine())
}

var t int

func main() {
	t := parseInt(readFields()[0])
	for tc := 0; tc < t; tc++ {
      f := readFields()
      a,b,c := parseInt64(f[0]), parseInt64(f[1]), parseInt64(f[2])
      if a < c {
        Print(1)
      } else {
        Print(-1)
      }
      Print(" ")
      if a*b > c {
        Print(b)
      } else {
        Print(-1)
      }
      Println()
    }
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		a, b, c := readThreeNums(reader)
		x, y := solve(a, b, c)
		fmt.Printf("%d %d\n", x, y)
	}
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(a, b, c int) (x int, y int) {
	if a >= c {
		x = -1
	} else {
		// A(x) < B(x) => a * x < [(x + b-1)/b * c)
		x = 1
	}

	if a > c {
		y = 1
	} else {
		// a <= c
		// A(y) > B(y) => a * y > [(y + b - 1) / b * c)
		// a * y > y / b * c, let y divides, y = b * n => a * b * n > n * c
		// => a * b > c
		if int64(a)*int64(b) > int64(c) {
			y = b
		} else {
			y = -1
		}
	}
	return
}

package main
import "fmt"

func main() {
    var t int;
    fmt.Scanln(&t);
    for kchk:=1; kchk<=t; kchk++{
    	var a, b, c int;
    	fmt.Scanln(&a, &b, &c);
    	if a >= c{
    		fmt.Println("-1 2");
    		continue;
    	}
    	var x int = -1;
    	if int64(a)*int64(b)>int64(c){
    		x = b;
    	}
    	fmt.Println(1,x);
    }

}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a,b,c int64
		fmt.Scanf("%d %d %d\n", &a, &b, &c)
		if b == 1 {
			if a == c {
				fmt.Println(-1, -1)
			} else if a > c {
				fmt.Println(-1, b)
			} else {
				fmt.Println(1, -1)
			}
			continue
		}

		if a <= (c / b) {
			fmt.Println(1, -1)
		} else if a >= c {
			fmt.Println(-1, b)
		} else {
			fmt.Println(1, b)
		}
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

/*
URL:
https://codeforces.com/contest/1373/problem/A
*/

package main

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

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	a, b, c int64
)

func main() {
	t = ReadInt()

	for i := 0; i < t; i++ {
		a, b, c = ReadInt64_3()

		solve()
	}
}

func solve() {
	var ans1, ans2 int64

	if a >= c {
		ans1 = -1
	} else {
		ans1 = 1
	}

	if a*b-c <= 0 {
		ans2 = -1
	} else {
		ans2 = b
	}

	fmt.Println(ans1, ans2)
}

func BinarySearch(initOK, initNG int64, isOK func(mid int64) bool) (ok int64) {
	ng := initNG
	ok = initOK
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}

	return ok
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

import (
	"fmt"
)

func main() {
	var t, a, b, c, out1, out2 int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d\n", &a, &b, &c)
		// fmt.Printf("a = %d b = %d c = %d", a, b, c)
		if a >= c {
			out1 = -1
		} else {
			out1 = 1
		}
		if float64(c) / float64(b) >= float64(a) {
			out2 = -1
		} else {
			out2 = b
		}
		fmt.Printf("%d %d\n", out1, out2)
	}
}

package main

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

var nTest int
var a, b, c, x1, x2 int64

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	fmt.Fscan(in, &nTest)
	for t := 0; t < nTest; t++ {
		fmt.Fscan(in, &a, &b, &c)

		if a < c {
			x1 = 1
		} else {
			x1 = -1
		}

		if a*b <= c {
			x2 = -1
		} else {
			x2 = b
		}
		fmt.Fprintln(out, x1, x2)
	}

	out.Flush()
}

package main

import "fmt"

func main(){
    var t int;
    fmt.Scan(&t);
    for t > 0{
        var a,b,c int64;
        fmt.Scan(&a,&b,&c);
        if a < c{
            fmt.Print("1 ");
        } else {
            fmt.Print("-1 ");
        }
        if a*b <= c{
            fmt.Println(-1);
        } else{
            fmt.Println(b);
        }
        t--;
    }
}

package main

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

func main() {
	t := NextInt()
	for t > 0 {
		t--
		a, b, c := NextInt(), NextInt(), NextInt()
		ans1, ans2 := -1, -1
		if int64(a) * int64(b) > int64(c) {
			ans2 = b
		}
		if a < c {
			ans1 = 1
		}
		fmt.Println(ans1, ans2)
	}
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func Next() string {
	sc.Scan()
	return sc.Text()
}

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

func NextDouble() float64 {
	f, err := strconv.ParseFloat(Next(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

package main

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

var reader *bufio.Reader

func parseInt(s string) int {
	return int(parseInt64(s))
}

func parseInt64(s string) int64 {
	x, _ := strconv.ParseInt(s, 10, 64)
	return x
}

func readLine() string {
	if reader == nil {
		reader = bufio.NewReader(os.Stdin)
	}
	s, _ := reader.ReadString('\n')
	return strings.TrimSuffix(s, "\n")
}

func readFields() []string {
	return strings.Fields(readLine())
}

var t int

func main() {
	t := parseInt(readFields()[0])
	for tc := 0; tc < t; tc++ {
      f := readFields()
      a,b,c := parseInt(f[0]), parseInt(f[1]), parseInt(f[2])
      if a < c {
        Print(1)
      } else {
        Print(-1)
      }
      Print(" ")
      if a*b > c {
        Print(b)
      } else {
        Print(-1)
      }
      Println()
    }
}

package main
import "fmt"

func main() {
    var t int;
    fmt.Scanln(&t);
    for kchk:=1; kchk<=t; kchk++{
    	var a, b, c int;
    	fmt.Scanln(&a, &b, &c);
    	if a >= c{
    		fmt.Println("-1 2");
    		continue;
    	}
    	var x int = -1;
    	if b*a>c{
    		x = b;
    	}
    	fmt.Println(1,x);
    }

}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a,b,c int64
		fmt.Scanf("%d %d %d", &a, &b, &c)
		if b == 1 {
			if a == c {
				fmt.Println(-1, -1)
			} else if a > c {
				fmt.Println(-1, 1)
			} else {
				fmt.Println(1, -1)
			}
			continue
		}

		if a * b <= c {
			fmt.Println(1, -1)
		} else if a >= c {
			fmt.Println(-1, 2)
		} else {
			fmt.Println(1 , b)
		}
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a,b,c int64
		fmt.Scanf("%d %d %d", &a, &b, &c)
		if b == 1 {
			if a == c {
				fmt.Println(-1, -1)
			} else if a > c {
				fmt.Println(-1, 1)
			} else {
				fmt.Println(1, -1)
			}
			continue
		}
		if a * b <= c {
			fmt.Println(1, -1)
		} else if a > c {
			fmt.Println(-1, 1)
		} else {
			fmt.Println(1 , b)
		}
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a,b,c int64
		fmt.Scanf("%d %d %d", &a, &b, &c)
		if b == 1 {
			if a == c {
				fmt.Println(-1, -1)
			} else if a > c {
				fmt.Println(-1, 1)
			} else {
				fmt.Println(1, -1)
			}
			continue
		}
		if a * b <= c {
			fmt.Println("1 -1")
		} else if a > c {
			fmt.Println("-1 1")
		} else {
			fmt.Println("1 ", b)
		}
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import "fmt"

func main(){
    var t int;
    fmt.Scan(&t);
    for t > 0{
        var a,b,c int;
        fmt.Scan(&a,&b,&c);
        if a < c{
            fmt.Print("1 ");
        } else {
            fmt.Print("-1 ");
        }
        if a*b <= c{
            fmt.Println(-1);
        } else{
            fmt.Println(b);
        }
        t--;
    }
}

package main

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

func main() {
	t := NextInt()
	for t > 0 {
		t--
		a, b, c := NextInt(), NextInt(), NextInt()
		ans1, ans2 := -1, -1
		if int64(a) * int64(b) > int64(c) {
			ans2 = 1
		}
		if a < c {
			ans1 = 1
		}
		fmt.Println(ans1, ans2)
	}
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func Next() string {
	sc.Scan()
	return sc.Text()
}

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

func NextDouble() float64 {
	f, err := strconv.ParseFloat(Next(), 64)
	if err != nil {
		panic(err)
	}
	return f
}