Ashish and Vivek play a game on a matrix consisting of $$$n$$$ rows and $$$m$$$ columns, where they take turns claiming cells. Unclaimed cells are represented by $$$0$$$, while claimed cells are represented by $$$1$$$. The initial state of the matrix is given. There can be some claimed cells in the initial state.In each turn, a player must claim a cell. A cell may be claimed if it is unclaimed and does not share a row or column with any other already claimed cells. When a player is unable to make a move, he loses and the game ends.If Ashish and Vivek take turns to move and Ashish goes first, determine the winner of the game if both of them are playing optimally.Optimal play between two players means that both players choose the best possible strategy to achieve the best possible outcome for themselves.

The first line consists of a single integer $$$t$$$ $$$(1 \le t \le 50)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case consists of two space-separated integers $$$n$$$, $$$m$$$ $$$(1 \le n, m \le 50)$$$ — the number of rows and columns in the matrix. The following $$$n$$$ lines consist of $$$m$$$ integers each, the $$$j$$$-th integer on the $$$i$$$-th line denoting $$$a_{i,j}$$$ $$$(a_{i,j} \in \{0, 1\})$$$.

For each test case if Ashish wins the game print "Ashish" otherwise print "Vivek" (without quotes).

NoteFor the first case: One possible scenario could be: Ashish claims cell $$$(1, 1)$$$, Vivek then claims cell $$$(2, 2)$$$. Ashish can neither claim cell $$$(1, 2)$$$, nor cell $$$(2, 1)$$$ as cells $$$(1, 1)$$$ and $$$(2, 2)$$$ are already claimed. Thus Ashish loses. It can be shown that no matter what Ashish plays in this case, Vivek will win. For the second case: Ashish claims cell $$$(1, 1)$$$, the only cell that can be claimed in the first move. After that Vivek has no moves left.For the third case: Ashish cannot make a move, so Vivek wins.For the fourth case: If Ashish claims cell $$$(2, 3)$$$, Vivek will have no moves left.

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, m := readTwoNums(reader)

		A := make([][]int, n)
		for i := 0; i < n; i++ {
			A[i] = readNNums(reader, m)
		}

		fmt.Println(solve(n, m, A))
	}
}

const Ashish = "Ashish"
const Vivek = "Vivek"

func solve(n, m int, A [][]int) string {
	row := make([]bool, n)
	col := make([]bool, m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if A[i][j] == 1 {
				row[i] = true
				col[j] = true
			}
		}
	}
	var rc, cc int

	for i := 0; i < n; i++ {
		if !row[i] {
			rc++
		}
	}

	for j := 0; j < m; j++ {
		if !col[j] {
			cc++
		}
	}
	x := min(rc, cc)
	if x%2 == 1 {
		return Ashish
	}
	return Vivek
}

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, m := 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		a := make([][]int, n)
		okn := make([]int, n)
		okm := make([]int, m)
		for i := 0; i < n; i++ {
			a[i] = make([]int, m)
			for j := 0; j < m; j++ {
				fmt.Fscanf(in, "%d", &a[i][j])
				if a[i][j] == 1 {
					okn[i] = 1
					okm[j] = 1
				}
			}
			fmt.Fscanf(in, "\n")
		}
		o, p := 0, 0
		for i := 0; i < n; i++ {
			if okn[i] == 0 {
				o++
			}
		}
		for i := 0; i < m; i++ {
			if okm[i] == 0 {
				p++
			}
		}
		if o > p {
			o = p
		}
		if o%2 == 0 {
			fmt.Fprintf(out, "Vivek\n")
		} else {
			fmt.Fprintf(out, "Ashish\n")
		}
	}
	return
}

// https://codeforces.com/contest/x/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var T int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n, m int
	fmt.Fscan(input, &n, &m)
	ai := make([]bool, n)
	aj := make([]bool, m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			var tmp int
			fmt.Fscan(input, &tmp)
			if tmp == 1 {
				ai[i] = ai[i] || true
				aj[j] = aj[j] || true
			}
		}
	}
	ans := 0
	i, j := 0, 0
	for i < n && j < m {
		for i < n && ai[i] {i++; continue}
		for j < m && aj[j] {j++; continue}
		if i >= n || j >= m {break}
		ans++
		i++; j++;
	}
	if ans % 2 == 1 {
		fmt.Println("Ashish")
	} else {
		fmt.Println("Vivek")
	}
}

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

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for k := 0; k < t; k++ {
		var n, m int
		fmt.Scanf("%d %d\n", &n, &m)
		rows := make([]int, n, n)
		cols := make([]int, m, m)
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				var a int
				if j+1 == m {
					fmt.Scanf("%d\n", &a)
				} else {
					fmt.Scanf("%d", &a)
				}
				if a == 1 {
					rows[i] = 1
					cols[j] = 1
				}
			}
		}
		freeRows, freeCols := 0, 0
		for i := 0; i < n; i++ {
			freeRows += rows[i]
		}
		for i := 0; i < m; i++ {
			freeCols += cols[i]
		}
		freeRows = n - freeRows
		freeCols = m - freeCols

		freeCells := freeCols
		if freeRows < freeCols {
			freeCells = freeRows
		}
		if freeCells%2 == 1 {
			fmt.Println("Ashish")
		} else {
			fmt.Println("Vivek")
		}
	}

}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	buff := make([]byte, 16 * 1024 * 1024)

	scanner.Buffer(buff, 1024 * 1024)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {

		scanner.Scan()

		NM := scanner.Text()

		nm := strings.Fields(NM)

		n, _ := strconv.Atoi(nm[0])
		m, _ := strconv.Atoi(nm[1])

		matrix := make([][]int, n)

		for i := 0 ; i< n; i++ {
			scanner.Scan()

			ms := scanner.Text()

			parts := strings.Fields(ms)

			matrix[i] = make([]int, m)

			for p:=0; p < m; p ++ {
				col, _ := strconv.Atoi(parts[p])

				matrix[i][p] = col

			}
		}

		ans := solve1(matrix)

		fmt.Println(ans)
	}
}

func solve1(matrix [][]int) string {
	n := len(matrix)
	m := len(matrix[0])

	sum := n * m

	rows := make([]bool, n)
	cols := make([]bool, m)

	rClaimed := 0
	cClaimed := 0

	for i := 0; i < n; i++ {
		for j := 0; j < m; j ++ {
			if matrix[i][j] == 1 {
				if !rows[i] {
					sum -= m - cClaimed
					rClaimed++
					rows[i] = true
				}
				if !cols[j] {
					sum -= n - rClaimed
					cClaimed++
					cols[j] = true
				}
			}
		}
	}

	if sum <= 0 {
		return "Vivek"
	}

	var k int
	for k = 0; ; k ++ {
		if sum <= 0 {
			break
		}
		sum -= m - cClaimed
		rClaimed++
		sum -= n - rClaimed
		cClaimed ++
	}

	if k % 2 == 0 {
		return "Vivek"
	}
	return "Ashish"
}

package main

import (
	"fmt"
)

type coord struct {
	x int
	y int
}

//refactor this using methods
func checkIfRowFree(m []int) bool {
	for i := range m {
		if m[i] == 1 {
			return false
		}
	}

	return true
}

//checkIfColfree(matrix, 3)

func checkIfColFree(m [][]int, col int) bool {
	for i := range m {
		if m[i][col] == 1 {
			return false
		}
	}

	return true
}

func main() {
	var t int
	var n, m int
	var mElem int
	var matrix [][]int
	var ashishWin bool

	// scanner := bufio.NewScanner(os.Stdin)
	// scanner.Scan()

	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		ashishWin = false

		fmt.Scan(&n, &m)

		matrix = make([][]int, n)
		for j := range matrix {
			matrix[j] = make([]int, m)
		}

		for j := range matrix {
			for k := range matrix[j] {
				fmt.Scan(&mElem)
				matrix[j][k] = mElem
			}
			// fmt.Scanf("\n")
		}

		toClaim := coord{x: 0, y: 0}
		var isRowFree, isColFree bool

		// greedy algorithm
		for toClaim.x < n && toClaim.y < m {
			isRowFree = checkIfRowFree(matrix[toClaim.x])
			if !isRowFree {
				toClaim.x++
				continue
			}
			isColFree = checkIfColFree(matrix, toClaim.y)
			if !isColFree {
				toClaim.y++
				continue
			}

			matrix[toClaim.x][toClaim.y] = 1
			ashishWin = !ashishWin
			toClaim.x++
		}

		if ashishWin {
			fmt.Println("Ashish")
		} else {
			fmt.Println("Vivek")
		}
	}
}

package main

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

func main() {
	t := nextInt()
	for i := 0; i < t; i++ {
		n, m := nextInt(), nextInt()
		grid := make([][]int, n)
		for y := 0; y < n; y++ {
			grid[y] = nextInts(m)
		}
		fmt.Println(solve(grid))
	}
}

func solve(grid [][]int) string {
	Y := len(grid)
	X := len(grid[0])

	usedX := make(map[int]bool, X)
	usedY := make(map[int]bool, Y)

	for y := 0; y < Y; y++ {
		for x := 0; x < X; x++ {
			if grid[y][x] == 1 {
				usedX[x] = true
				usedY[y] = true
			}
		}
	}

	if min(X-len(usedX), Y-len(usedY))%2 == 1 {
		return "Ashish"
	} else {
		return "Vivek"
	}
}

func min(xs ...int) int {
	ret := xs[0]
	for _, x := range xs[1:] {
		if ret > x {
			ret = x
		}
	}
	return ret
}

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 {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

/*
URL:
https://codeforces.com/contest/1365/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

	n, m int
	A    [][]int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n, m = ReadInt2()
		A = [][]int{}
		for j := 0; j < n; j++ {
			row := ReadIntSlice(m)
			A = append(A, row)
		}

		solve()
	}
}

func solve() {
	r, c := n, m

	fr := 0
	for i := 0; i < n; i++ {
		if !isRowOK(i) {
			fr++
		}
	}
	fc := 0
	for j := 0; j < m; j++ {
		if !isColOK(j) {
			fc++
		}
	}
	// PrintfDebug("filled row: %d, filled column: %d\n", fr, fc)

	r -= fr
	c -= fc

	mini := Min(r, c)

	if mini%2 == 0 {
		fmt.Println("Vivek")
	} else {
		fmt.Println("Ashish")
	}
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func isRowOK(id int) bool {
	for i := 0; i < m; i++ {
		if A[id][i] == 1 {
			return false
		}
	}
	return true
}

func isColOK(id int) bool {
	for j := 0; j < n; j++ {
		if A[j][id] == 1 {
			return false
		}
	}
	return true
}

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

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

var nTest, n, m int
var a [55][55]int

func main() {
	fmt.Scan(&nTest)

	for i := 0; i < nTest; i++ {
		fmt.Scan(&n, &m)
		var row [55]bool
		var col [55]bool

		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Scan(&a[i][j])

				if a[i][j] == 1 {
					row[i] = true
					col[j] = true
				}
			}
		}

		nRow := 0
		for i := 0; i < n; i++ {
			if row[i] {
				nRow++
			}
		}

		nCol := 0
		for i := 0; i < m; i++ {
			if col[i] {
				nCol++
			}
		}

		var step int
		if n-nRow < m-nCol {
			step = n - nRow
		} else {
			step = m - nCol
		}

		if step&1 == 1 {
			fmt.Println("Ashish")
		} else {
			fmt.Println("Vivek")
		}

	}
}

package main

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

var nTest, n, m int
var a [55][55]int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscanf(in, "%d\n", &nTest)

	for i := 0; i < nTest; i++ {
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		var row [55]bool
		var col [55]bool

		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Fscanf(in, "%d", &a[i][j])

				if a[i][j] == 1 {
					row[i] = true
					col[j] = true
				}
			}
			fmt.Fscanf(in, "\n")
		}

		nRow := 0
		for i := 0; i < n; i++ {
			if !row[i] {
				nRow++
			}
		}

		nCol := 0
		for i := 0; i < m; i++ {
			if !col[i] {
				nCol++
			}
		}

		var step int
		if nRow < nCol {
			step = nRow
		} else {
			step = nCol
		}

		if step&1 == 1 {
			fmt.Fprintf(out, "Ashish\n")
		} else {
			fmt.Fprintf(out, "Vivek\n")
		}
	}
	out.Flush()
}

package main

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

var nTest, n, m int
var a [55][55]int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscan(in, &nTest)

	for i := 0; i < nTest; i++ {
		fmt.Fscan(in, &n, &m)
		var row [55]bool
		var col [55]bool

		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Fscan(in, &a[i][j])

				if a[i][j] == 1 {
					row[i] = true
					col[j] = true
				}
			}
			fmt.Fscanln(in)
		}

		nRow := 0
		for i := 0; i < n; i++ {
			if !row[i] {
				nRow++
			}
		}

		nCol := 0
		for i := 0; i < m; i++ {
			if !col[i] {
				nCol++
			}
		}

		var step int
		if nRow < nCol {
			step = nRow
		} else {
			step = nCol
		}

		if step&1 == 1 {
			fmt.Fprintln(out, "Ashish")
		} else {
			fmt.Fprintln(out, "Vivek")
		}
	}
	out.Flush()
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1365A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var t, n, m int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m)
		r, c := 0, 0
		a := make([][]byte, n)
		for i := range a {
			a[i] = make([]byte, m)
			for j := range a[i] {
				Fscan(in, &a[i][j])
			}
			if !bytes.Contains(a[i], []byte{1}) {
				r++
			}
		}
	o:
		for j := 0; j < m; j++ {
			for _, r := range a {
				if r[j] == 1 {
					continue o
				}
			}
			c++
		}
		if c < r {
			r = c
		}
		if r&1 == 1 {
			Fprintln(out, "Ashish")
		} else {
			Fprintln(out, "Vivek")
		}
	}
}

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

package main

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

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int64
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var n, m int
		var mat [][]int
		fmt.Fscanf(in, "%v %v\n", &n, &m)
		row := make([]int, n, n)
		col := make([]int, m, m)
		for i := 0; i < n;i++ {
			line := make([]int, m, m)
			for j := 0;j < m;j++ {
				fmt.Fscanf(in, "%v", &line[j])
				if line[j] == 1{
					row[i] = 1
					col[j] = 1
				}
			}
			fmt.Fscanf(in, "\n")
			mat = append(mat, line)
		}
		var suma, sumb = 0, 0
		for i := 0; i < n;i++ {
			if row[i] == 0 {
				suma++
			}
		}
		for i := 0; i < m;i++ {
			if col[i] == 0 {
				sumb++
			}
		}
		if min(suma, sumb) % 2 == 0 {
			fmt.Fprintln(out, "Vivek")
		} else{
			fmt.Fprintln(out, "Ashish")
		}
	}
	return
}

package main
import (
        "fmt"
        "os"
        "bufio"
)
func worker(in *bufio.Reader) {
    var n, m, tmp int

    fmt.Fscan(in, &n, &m)

    rows := make([]int, n+1)
    cols := make([]int, m+1)
    for i := 1; i <= n; i++ {
        rows[i] = 1
    }
    for i := 1; i <= m; i++ {
        cols[i] = 1
    }
    for i := 1; i <= n; i++ {
        for j := 1; j <= m; j++ {
            fmt.Fscan(in, &tmp)
            if tmp == 1 {
                rows[i] = 0
                cols[j] = 0
            }
        }
    }
    rowCnt, colCnt := 0, 0
    for i := 1; i <= n; i++ {
        if rows[i] == 1 {
            rowCnt++;
        }
    }
    for i := 1; i <= m; i++ {
        if cols[i] == 1 {
            colCnt++;
        }
    }
    if rowCnt > colCnt {
        rowCnt = colCnt
    }
    if rowCnt % 2 == 0 {
        fmt.Println("Vivek")
    } else {
        fmt.Println("Ashish")
    }
}
func main(){
    var t int
    in := bufio.NewReader(os.Stdin)
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        worker(in)
    }
}

package main

import (
	"fmt"
)

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

func main() {
	var t int
	fmt.Scan(&t)
	for tst := 0; tst < t; tst++ {
		var n int
		var m int
		fmt.Scan(&n, &m)
		ui := make(map[int]int)
		uj := make(map[int]int)
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				var x int
				fmt.Scan(&x)
				if x == 1 {
					ui[i] = 1
					uj[j] = 1
				}
			}
		}

		cnt := min(n - len(ui), m - len(uj))
		if cnt % 2 == 0 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}

package main

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

func fastGetInt(b []byte) int {
	neg := false
	if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n
	}
	return n
}

//========== Implement Algorithm =======================
func solution(rows int, cols int) string {
	retVal := "Vivek"
	//fmt.Println(rows, cols)
	if rows > cols {
		rows, cols = cols, rows
	}

	if rows%2 == 1 {
		retVal = "Ashish"

	}
	return retVal
}

func checkNumZero(freeCols []int) int {
	count := 0
	for x := 0; x < len(freeCols); x++ {
		if freeCols[x] == 0 {
			count++
		}
	}
	return count
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	//================== Variables used ====================
	var num, x, y, freeRows, freeCols int
	var ret string
	//var freeCol []int
	//======================================================

	//============== Get return value from File ============
	if len(os.Args) >= 2 {

		file, err := os.Open(os.Args[1])
		if err != nil {
			log.Fatalf("failed opening file: %s", err)
		}
		scanner = bufio.NewScanner(file)
		defer file.Close()

	}
	scanner.Split(bufio.ScanWords)
	//======================= I/O ==========================
	scanner.Scan()
	num = fastGetInt(scanner.Bytes())
	for i := 0; i < num; i++ {
		scanner.Scan()
		x = fastGetInt(scanner.Bytes())
		scanner.Scan()
		y = fastGetInt(scanner.Bytes())
		freeCol := make([]int, y)
		freeRows = 0
		for x1 := 0; x1 < x; x1++ {
			hasFreeRow := true
			for c := 0; c < y; c++ {
				scanner.Scan()
				newNum := fastGetInt(scanner.Bytes())
				if newNum != 0 {
					hasFreeRow = false
					freeCol[c] = 1
				}
			}
			if hasFreeRow {
				freeRows++
			}
		}
		freeCols = checkNumZero(freeCol)
		ret = solution(freeRows, freeCols)
		fmt.Println(ret)
	}
	//======================================================
	//ret = solution(freeRows, freeCols)
	//==================== OUTPUT ==========================
	//fmt.Println(ret)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	scan := func(x ...interface{}) (n int, err error) {
		return fmt.Fscan(in, x...)
	}
	println := func(x ...interface{}) (n int, err error) {
		return fmt.Fprintln(out, x...)
	}

	var t int
	for scan(&t); t > 0; t-- {
		var n, m int
		scan(&n, &m)
		isZeroCol := make([]bool, m)
		for i := range isZeroCol {
			isZeroCol[i] = true
		}
		numZeroRows := 0
		for i := 0; i < n; i++ {
			allZeros := true
			var a int8
			for j := 0; j < m; j++ {
				if scan(&a); a != 0 {
					isZeroCol[j] = false
					allZeros = false
				}
			}
			if allZeros {
				numZeroRows++
			}
		}
		numZeroColumns := 0
		for _, v := range isZeroCol {
			if v {
				numZeroColumns++
			}
		}
		var numSteps int
		if numZeroColumns < numZeroRows {
			numSteps = numZeroColumns
		} else {
			numSteps = numZeroRows
		}

		if numSteps%2 == 0 {
			println("Vivek")
		} else {
			println("Ashish")
		}
	}
}

package main

import (
	"fmt"
)
type Game struct {
	board  []bool
	Width  int
	Height int
}

func MakeGame(width, height int) Game {
	return Game{
		make([]bool, width * height),
		width,
		height,
	}
}
func (g *Game) setField(x,y int, value bool) {
	g.board[x + y * g.Width] = value
}
func (g Game) Board(x, y int) bool {
	//if x > g.Width {
	//	fmt.Printf("!!Got x: %v that is greater than width: %v\n", x, g.Width)
	//}
	return g.board[x + y * g.Width]
}

func (g Game) freeRows() (res int) {
	for x := 0; x < g.Width; x ++ {
		current := false
		for y := 0; y < g.Height; y++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Width - res
}

func (g Game) freeCols() (res int) {
	for y := 0; y < g.Height; y++ {
		current := false
		for x := 0; x < g.Width; x ++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Height - res
}

func (g Game) moves() int {
	cols, rows := g.freeCols(), g.freeRows()
	if cols > rows {
		return rows
	} else {
		return cols
	}
}

func scanf(format string, vars ...interface{}) {
	var err error
	_, err = fmt.Scan(vars...)
	for err != nil {
		fmt.Printf("got an error: %v", err)
		_, err = fmt.Scan(vars)
	}
}

func main() {
	var testcases int
	_, _ = fmt.Scan(&testcases)
	for i := 0; i < testcases; i++ {
		var width, height int
		scanf("%d %d", &width, &height)
		game := MakeGame(width, height)
		for j := 0; j < width; j ++ {
			for k := 0; k < height; k++ {
				var value int
				scanf("%d", &value)
				game.setField(j, k, value == 1)
			}
		}
		res := game.moves()
		if res & 1 == 0 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}

package main

import "fmt"

const maxn = int(4e5 + 5)

var (
	t, n, m int
	a       [51][51]int
)

func main() {
	fmt.Scan(&t)
	for ; t > 0; t-- {
		fmt.Scan(&n, &m)
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Scan(&a[i][j])
			}
		}

		row := 0
		col := 0
		for i := 0; i < n; i++ {
			ok := true
			for j := 0; j < m; j++ {
				if a[i][j] == 1 {
					ok = false
					break
				}
			}

			if ok {
				row++
			}
		}

		for j := 0; j < m; j++ {
			ok := true
			for i := 0; i < n; i++ {
				if a[i][j] == 1 {
					ok = false
					break
				}
			}

			if ok {
				col++
			}
		}

		if col < row {
			row = col
		}

		if row&1 == 1 {
			fmt.Println("Ashish")
		} else {
			fmt.Println("Vivek")
		}
	}
}

// Author: sighduck
// URL: https://codeforces.com/contest/1365/problem/A

package main

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

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

func Solve(n int, m int, matrix [][]int) string {
	rows := make([]bool, n)
	columns := make([]bool, m)
	for i := 0; i < n; i++ {
		rows[i] = true
	}
	for i := 0; i < m; i++ {
		columns[i] = true
	}
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if matrix[i][j] == 1 {
				rows[i] = false
				columns[j] = false
			}
		}
	}
	rowCount := 0
	columnCount := 0
	for _, elem := range rows {
		if elem {
			rowCount += 1
		}
	}
	for _, elem := range columns {
		if elem {
			columnCount += 1
		}
	}
	if min(rowCount, columnCount)%2 == 1 {
		return "Ashish"
	}
	return "Vivek"
}

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

	var t int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 0; i < t; i++ {
		var n, m int
		fmt.Fscanf(reader, "%d %d\n", &n, &m)
		matrix := make([][]int, n)
		for i := 0; i < n; i++ {
			matrix[i] = make([]int, m)
			for j := 0; j < m; j++ {
				fmt.Fscanf(reader, "%d ", &matrix[i][j])
			}
			fmt.Fscanf(reader, "\n")
		}
		fmt.Fprintf(writer, "%s\n", Solve(n, m, matrix))
	}
}

package main

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

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	Int64() int64
	UInt64() uint64
	String() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) Int64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) UInt64() uint64 {
	impl.Scan()
	bb := impl.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) String() string {
	impl.Scan()
	return impl.Text()
}

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 abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

const (
	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.Int64()
	for ; t > 0; t-- {
		n := reader.Int64()
		m := reader.Int64()
		mat := make([][]int64, n)
		for i := range mat {
			mat[i] = make([]int64, m)
			for j := range mat[i] {
				mat[i][j] = reader.Int64()
			}
		}
		writer.Printf("%s\n", sol(mat))
	}
}

func sol(mat [][]int64) string {
	for i := range mat {
		for j := range mat[i] {
			if mat[i][j] == 1 {
				for x := range mat[i] {
					if mat[i][x] == 0 {
						mat[i][x] = 2
					}
				}
				for x := range mat {
					if mat[x][j] == 0 {
						mat[x][j] = 2
					}
				}
				mat[i][j] = 2
			}
		}
	}
	//writer.Printf("%+v\n", mat)

	total := 0
	for i := range mat {
		for j := range mat[i] {
			if mat[i][j] == 0 {
				total++
				for x := range mat[i] {
					mat[i][x] = 2
				}
				for x := range mat {
					mat[x][j] = 2
				}
			}
		}
	}
	if total & 1 == 1 {
		return "Ashish"
	}
	return "Vivek"
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	buff := make([]byte, 2 * 1024 * 1024)

	scanner.Buffer(buff, 1024 * 1024)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {

		scanner.Scan()

		NM := scanner.Text()

		nm := strings.Fields(NM)

		n, _ := strconv.Atoi(nm[0])
		m, _ := strconv.Atoi(nm[1])

		matrix := make([][]int, n)

		for i := 0 ; i< n; i++ {
			scanner.Scan()

			ms := scanner.Text()

			parts := strings.Fields(ms)

			matrix[i] = make([]int, m)

			for p:=0; p < m; p ++ {
				col, _ := strconv.Atoi(parts[p])

				matrix[i][p] = col

			}
		}

		ans := solve1(matrix)

		fmt.Println(ans)
	}
}

func solve1(matrix [][]int) string {
	n := len(matrix)
	m := len(matrix[0])

	sum := n * m

	rows := make([]bool, n)
	cols := make([]bool, m)

	rClaimed := 0
	cClaimed := 0

	for i := 0; i < n; i++ {
		for j := 0; j < m; j ++ {
			if matrix[i][j] == 1 {
				if !rows[i] {
					sum -= n - cClaimed
					rClaimed++
					rows[i] = true
				}
				if !cols[j] {
					sum -= m - rClaimed
					cClaimed++
					cols[j] = true
				}

			}
		}
	}

	if sum <= 0 {
		return "Vivek"
	}

	var k int
	for k = 0; ; k ++ {
		if sum <= 0 {
			break
		}
		sum -= n - cClaimed
		rClaimed++
		sum -= m - rClaimed
		cClaimed ++
	}

	if k % 2 == 0 {
		return "Vivek"
	}
	return "Ashish"
}

// 1 0 0
// 0 0 0
// 1 0 0

package main

import (
	"fmt"
)

type coord struct {
	x int
	y int
}

//refactor this using methods
func checkIfRowFree(m []int) bool {
	for i := range m {
		if m[i] == 1 {
			return false
		}
	}

	return true
}

//checkIfColfree(matrix, 3)

func checkIfColFree(m [][]int, col int) bool {
	for i := range m {
		if m[i][col] == 1 {
			return false
		}
	}

	return true
}

func main() {
	var t int
	var n, m int
	var mElem int
	var matrix [][]int

	fmt.Scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d\n", &n, &m)

		matrix = make([][]int, n)
		for j := range matrix {
			matrix[j] = make([]int, m)
		}

		for j := range matrix {
			for k := range matrix[j] {
				fmt.Scanf("%d", &mElem)
				matrix[j][k] = mElem
			}
		}

		var ashishWin bool = false
		toClaim := coord{x: 0, y: 0}
		var isRowFree, isColFree bool

		// greedy algorithm
		for toClaim.x < n && toClaim.y < m {
			isRowFree = checkIfRowFree(matrix[toClaim.x])
			if !isRowFree {
				toClaim.x++
				continue
			}
			isColFree = checkIfColFree(matrix, toClaim.y)
			if !isColFree {
				toClaim.y++
				continue
			}

			matrix[toClaim.x][toClaim.y] = 1
			ashishWin = !ashishWin
			toClaim.x++
		}

		if ashishWin {
			fmt.Println("Ashish")
		} else {
			fmt.Println("Vivek")
		}
	}
}

package main

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

func main() {
	t := nextInt()
	for i := 0; i < t; i++ {
		n, m := nextInt(), nextInt()
		grid := make([][]int, n)
		for y := 0; y < n; y++ {
			grid[y] = nextInts(m)
		}
		fmt.Println(solve(grid))
	}
}

func solve(grid [][]int) string {
	Y := len(grid)
	X := len(grid[0])

	usedX := make(map[int]bool, X)
	usedY := make(map[int]bool, Y)

	for y := 0; y < Y; y++ {
		for x := 0; x < X; x++ {
			if grid[y][x] == 1 {
				usedX[x] = true
				usedY[y] = true
			}
		}
	}

	if min(len(usedX), len(usedY))%2 == 1 {
		return "Ashish"
	} else {
		return "Vivek"
	}
}

func min(xs ...int) int {
	ret := xs[0]
	for _, x := range xs[1:] {
		if ret > x {
			ret = x
		}
	}
	return ret
}

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 {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

package main

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

func main() {
	t := nextInt()
	for i := 0; i < t; i++ {
		n, m := nextInt(), nextInt()
		grid := make([][]int, n)
		for y := 0; y < n; y++ {
			grid[y] = nextInts(m)
		}
		fmt.Println(solve(grid))
	}
}

func solve(grid [][]int) string {
	Y := len(grid)
	X := len(grid[0])

	usedX := make(map[int]bool, X)
	usedY := make(map[int]bool, Y)

	for y := 0; y < Y; y++ {
		for x := 0; x < X; x++ {
			if grid[y][x] == 1 {
				usedX[x] = true
				usedY[y] = true
			}
		}
	}

	turn := 0
	for {
		if len(usedX) == X || len(usedY) == Y {
			if turn%2 == 0 {
				return "Vivek"
			} else {
				return "Ashish"
			}
		}
		for x := 0; x < X; x++ {
			if usedX[x] {
				continue
			}
			usedX[x] = true
			break
		}
		for y := 0; y < X; y++ {
			if usedY[y] {
				continue
			}
			usedY[y] = true
			break
		}
		turn++
	}
}

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 {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

package main

import "fmt"

var nTest, n, m int
var a [55][55]int

func fill(x, y int) {
	dx := []int{0, 0, 1, -1}
	dy := []int{1, -1, 0, 0}

	for i := 0; i < 4; i++ {
		if x+dx[i] < n && x+dx[i] >= 0 && y+dy[i] < m && y+dy[i] >= 0 {
			a[x+dx[i]][y+dy[i]] = -1
		}
	}
}

func move() (int, int) {
	bestCnt := 0
	bestx := -1
	besty := -1
	dx := []int{0, 0, 1, -1}
	dy := []int{1, -1, 0, 0}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if a[i][j] != 0 {
				continue
			}
			cnt := 0
			for k := 0; k < 4; k++ {
				nx := i + dx[k]
				ny := j + dy[k]

				if nx < n && nx >= 0 && ny < m && ny >= 0 && a[nx][ny] == 0 {
					cnt++
				}
			}

			if cnt > bestCnt {
				bestCnt = cnt
				bestx = i
				besty = j
			}
		}
	}

	return bestx, besty
}

func main() {
	fmt.Scan(&nTest)

	for i := 0; i < nTest; i++ {
		fmt.Scan(&n, &m)

		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Scan(&a[i][j])
			}
		}

		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				if a[i][j] == 1 {
					fill(i, j)
				}
			}
		}

		step := 0
		moveX, moveY := move()
		for moveX != -1 {
			step++
			a[moveX][moveY] = 1
			fill(moveX, moveY)
			moveX, moveY = move()
		}

		if step&1 == 1 {
			fmt.Println("Ashish")
		} else {
			fmt.Println("Vivek")
		}

	}
}

package main

import "fmt"

var nTest, n, m int
var a [55][55]int

func fill(x, y int) {
	dx := []int{0, 0, 1, -1}
	dy := []int{1, -1, 0, 0}

	for i := 0; i < 4; i++ {
		nx := x + dx[i]
		ny := y + dy[i]
		if nx >= 0 && nx < n && ny >= 0 && ny < n && a[nx][ny] == 0 {
			a[nx][ny] = -1
		}
	}
}

func move() (int, int) {
	bestCnt := -1
	bestx := -1
	besty := -1
	dx := []int{0, 0, 1, -1}
	dy := []int{1, -1, 0, 0}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if a[i][j] != 0 {
				continue
			}

			cnt := 0
			cannot := false
			for k := 0; k < 4; k++ {
				nx := i + dx[k]
				ny := j + dy[k]
				if nx < n && nx >= 0 && ny < m && ny >= 0 && a[nx][ny] == 1 {
					cannot = true
					break
				}

				if nx < n && nx >= 0 && ny < m && ny >= 0 && a[nx][ny] == 0 {
					cnt++
				}
			}

			if cannot {
				continue
			}

			if cnt > bestCnt {
				bestCnt = cnt
				bestx = i
				besty = j
			}
		}
	}

	return bestx, besty
}

func main() {
	fmt.Scan(&nTest)

	for i := 0; i < nTest; i++ {
		fmt.Scan(&n, &m)

		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Scan(&a[i][j])
			}
		}

		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				if a[i][j] == 1 {
					fill(i, j)
				}
			}
		}

		step := 0
		moveX, moveY := move()

		// fmt.Print(moveX, moveY)
		for moveX != -1 {
			step++
			a[moveX][moveY] = 1
			fill(moveX, moveY)
			moveX, moveY = move()
		}

		if step&1 == 1 {
			fmt.Println("Ashish")
		} else {
			fmt.Println("Vivek")
		}

	}
}

package main

import "fmt"

var nTest, n, m int
var a [55][55]int

func fill(x, y int) {
	dx := []int{0, 0, 1, -1}
	dy := []int{1, -1, 0, 0}

	for i := 0; i < 4; i++ {
		if x+dx[i] < n && x+dx[i] >= 0 && y+dy[i] < m && y+dy[i] >= 0 {
			a[x+dx[i]][y+dy[i]] = -1
		}
	}
}

func move() (int, int) {
	bestCnt := 0
	bestx := -1
	besty := -1
	dx := []int{0, 0, 1, -1}
	dy := []int{1, -1, 0, 0}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			cnt := 0
			for k := 0; k < 4; k++ {
				nx := i + dx[k]
				ny := j + dy[k]

				if nx < n && nx >= 0 && ny < m && ny >= 0 && a[nx][ny] == 0 {
					cnt++
				}
			}

			if cnt > bestCnt {
				bestCnt = cnt
				bestx = i
				besty = j
			}
		}
	}

	return bestx, besty
}

func main() {
	fmt.Scan(&nTest)

	for i := 0; i < nTest; i++ {
		fmt.Scan(&n, &m)

		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Scan(&a[i][j])
			}
		}

		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				if a[i][j] == 1 {
					fill(i, j)
				}
			}
		}

		step := 0
		moveX, moveY := move()
		for moveX != -1 {
			step++
			a[moveX][moveY] = 1
			fill(moveX, moveY)
			moveX, moveY = move()
		}

		if step&1 == 1 {
			fmt.Println("Ashish")
		} else {
			fmt.Println("Vivek")
		}

	}
}

package main

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

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int64
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var n, m int
		var mat [][]int
		fmt.Fscanf(in, "%v %v\n", &n, &m)
		row := make([]int, n, n)
		col := make([]int, m, m)
		for i := 0; i < n;i++ {
			line := make([]int, m, m)
			for j := 0;j < m;j++ {
				fmt.Fscanf(in, "%v", &line[j])
				if line[j] == 1{
					row[i] = 1
					col[j] = 1
				}
			}
			fmt.Fscanf(in, "\n")
			mat = append(mat, line)
		}
		var sum = 0
		for i := 0; i < min(m, n);i++ {
			if row[i] == 0 && col[i] == 0{
				sum++
			}
		}
		if n > m {
			for i := min(n, m);i < max(n, m);i++{
				if row[i] == 0 {
					sum++
				}
			}
		} else{
			for i := min(n, m);i < max(n, m);i++{
				if col[i] == 0 {
					sum++
				}
			}
		}
		if sum % 2 == 0 {
			fmt.Fprintln(out, "Vivek")
		} else{
			fmt.Fprintln(out, "Ashish")
		}
	}
	return
}

package main

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

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int64
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var n, m int
		var mat [][]int
		fmt.Fscanf(in, "%v %v\n", &n, &m)
		row := make([]int, n, n)
		col := make([]int, m, m)
		for i := 0; i < n;i++ {
			line := make([]int, m, m)
			for j := 0;j < m;j++ {
				fmt.Fscanf(in, "%v", &line[j])
				if line[j] == 1{
					row[i] = 1
					col[j] = 1
				}
			}
			fmt.Fscanf(in, "\n")
			mat = append(mat, line)
		}
		var sum = 0
		for i := 0; i < min(m, n);i++ {
			if row[i] == 0 && col[i] == 0{
				sum++
			}
		}
		if sum % 2 == 0 {
			fmt.Fprintln(out, "Vivek")
		} else{
			fmt.Fprintln(out, "Ashish")
		}
	}
	return
}

package main

import (
	"fmt"
)

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

func main() {
	var t int
	fmt.Scan(&t)
	for tst := 0; tst < t; tst++ {
		var n int
		var m int
		fmt.Scan(&n, &m)
		ui := make(map[int]int)
		uj := make(map[int]int)
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				var x int
				fmt.Scan(&x)
				if x == 1 {
					ui[i] = 1
					uj[j] = 1
				}
			}
		}

		cnt := min(n - len(ui), m - len(uj))
		if cnt % 2 == 1 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for tst := 0; tst < t; tst++ {
		var n int
		var m int

		fmt.Scanf("%d %d", &n, &m)
		cnt := 0
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				var x int
				fmt.Scanf("%d", &x)
				if x == 1 {
					cnt++
				}
			}
		}

		if cnt == 0 || (n * m - cnt) % 2 == 0 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for tst := 0; tst < t; tst++ {
		var n int
		var m int

		fmt.Scan(&n, &m)
		cnt := 0
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				var x int
				fmt.Scan(&x)
				if x == 1 {
					cnt++
				}
			}
		}

		if cnt == 0 || (n * m - cnt) % 2 == 0 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}

package main

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

func fastGetInt(b []byte) int {
	neg := false
	if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n
	}
	return n
}

//========== Implement Algorithm =======================
func solution(rows int, cols int) string {
	retVal := "Vivek"
	if rows > cols {
		rows, cols = cols, rows
	}

	if rows%2 == 1 {
		retVal = "Ashish"
	}
	return retVal
}

func checkNumNonZero(freeCols []int) int {
	count := 0
	for x := 0; x < len(freeCols); x++ {
		if freeCols[x] != 0 {
			count++
		}
	}
	return count
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	//================== Variables used ====================
	var num, x, y, freeRows, freeCols int
	var ret string
	//var freeCol []int
	//======================================================

	//============== Get return value from File ============
	if len(os.Args) >= 2 {

		file, err := os.Open(os.Args[1])
		if err != nil {
			log.Fatalf("failed opening file: %s", err)
		}
		scanner = bufio.NewScanner(file)
		defer file.Close()

	}
	scanner.Split(bufio.ScanWords)
	//======================= I/O ==========================
	scanner.Scan()
	num = fastGetInt(scanner.Bytes())
	for i := 0; i < num; i++ {
		scanner.Scan()
		x = fastGetInt(scanner.Bytes())
		scanner.Scan()
		y = fastGetInt(scanner.Bytes())
		freeCol := make([]int, y)
		freeRows = 0
		for x1 := 0; x1 < x; x1++ {
			hasFreeRow := true
			for c := 0; c < y; c++ {
				scanner.Scan()
				newNum := fastGetInt(scanner.Bytes())
				if newNum != 0 {
					hasFreeRow = false
					freeCol[c] = 1
				}
			}
			if hasFreeRow {
				freeRows++
			}
		}
		freeCols = checkNumNonZero(freeCol)
		ret = solution(freeRows, freeCols)
		fmt.Println(ret)
	}
	//======================================================
	//ret = solution(freeRows, freeCols)
	//==================== OUTPUT ==========================
	//fmt.Println(ret)
}

package main

import (
	"fmt"
)
type Game struct {
	board  []bool
	Width  int
	Height int
}

func MakeGame(width, height int) Game {
	return Game{
		make([]bool, width * height),
		width,
		height,
	}
}
func (g *Game) setField(x,y int, value bool) {
	g.board[x + y * g.Width] = value
}
func (g Game) Board(x, y int) bool {
	//if x > g.Width {
	//	fmt.Printf("!!Got x: %v that is greater than width: %v\n", x, g.Width)
	//}
	return g.board[x + y * g.Width]
}

func (g Game) freeRows() (res int) {
	for x := 0; x < g.Width; x ++ {
		current := false
		for y := 0; y < g.Height; y++ {
			current = current || g.Board(x,y)
		}
		fmt.Println()
		if current {
			res += 1
		}
	}
	return g.Width - res
}

func (g Game) freeCols() (res int) {
	for y := 0; y < g.Height; y++ {
		current := false
		for x := 0; x < g.Width; x ++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Height - res
}

func (g Game) moves() int {
	cols, rows := g.freeCols(), g.freeRows()
	if cols > rows {
		return rows
	} else {
		return cols
	}
}

func main() {
	testcases := 0
	_, _ = fmt.Scanf("%d", &testcases)
	for i := 0; i < testcases; i++ {
		var width, height int
		if _, err := fmt.Scanf("%d %d", &width, &height); err != nil {
			testcases --
			continue
		}
		game := MakeGame(width, height)
		for j := 0; j < width; j ++ {
			for k := 0; k < height; k++ {
				var value int
				fmt.Scanf("%d", &value)
				game.setField(j, k, value == 1)
			}
		}
		res := game.moves()
		fmt.Printf("moves %v\n", res)
		if res & 1 == 0 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}

package main

import (
	"fmt"
)
type Game struct {
	board  []bool
	Width  int
	Height int
}

func MakeGame(width, height int) Game {
	return Game{
		make([]bool, width * height),
		width,
		height,
	}
}
func (g *Game) setField(x,y int, value bool) {
	g.board[x + y * g.Width] = value
}
func (g Game) Board(x, y int) bool {
	//if x > g.Width {
	//	fmt.Printf("!!Got x: %v that is greater than width: %v\n", x, g.Width)
	//}
	return g.board[x + y * g.Width]
}

func (g Game) freeRows() (res int) {
	for x := 0; x < g.Width; x ++ {
		current := false
		for y := 0; y < g.Height; y++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Width - res
}

func (g Game) freeCols() (res int) {
	for y := 0; y < g.Height; y++ {
		current := false
		for x := 0; x < g.Width; x ++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Height - res
}

func (g Game) moves() int {
	cols, rows := g.freeCols(), g.freeRows()
	if cols > rows {
		return rows
	} else {
		return cols
	}
}

func scanf(format string, vars ...interface{}) {
	var err error
	_, err = fmt.Scan(vars...)
	for err != nil {
		fmt.Printf("got an error: %v", err)
		_, err = fmt.Scan(vars)
	}
}

func main() {
	testcases := 0
	_, _ = fmt.Scan("%d", &testcases)
	for i := 0; i < testcases; i++ {
		var width, height int
		scanf("%d %d", &width, &height)
		game := MakeGame(width, height)
		for j := 0; j < width; j ++ {
			for k := 0; k < height; k++ {
				var value int
				scanf("%d", &value)
				game.setField(j, k, value == 1)
			}
		}
		res := game.moves()
		if res & 1 == 0 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}

package main

import (
	"fmt"
)
type Game struct {
	board  []bool
	Width  int
	Height int
}

func MakeGame(width, height int) Game {
	return Game{
		make([]bool, width * height),
		width,
		height,
	}
}
func (g *Game) setField(x,y int, value bool) {
	g.board[x + y * g.Width] = value
}
func (g Game) Board(x, y int) bool {
	//if x > g.Width {
	//	fmt.Printf("!!Got x: %v that is greater than width: %v\n", x, g.Width)
	//}
	return g.board[x + y * g.Width]
}

func (g Game) freeRows() (res int) {
	for x := 0; x < g.Width; x ++ {
		current := false
		for y := 0; y < g.Height; y++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Width - res
}

func (g Game) freeCols() (res int) {
	for y := 0; y < g.Height; y++ {
		current := false
		for x := 0; x < g.Width; x ++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Height - res
}

func (g Game) moves() int {
	cols, rows := g.freeCols(), g.freeRows()
	if cols > rows {
		return rows
	} else {
		return cols
	}
}

func main() {
	testcases := 0
	_, _ = fmt.Scanf("%d", &testcases)
	for i := 0; i < testcases; i++ {
		var width, height int
		if _, err := fmt.Scanf("%d %d", &width, &height); err != nil {
			testcases --
			continue
		}
		game := MakeGame(width, height)
		for j := 0; j < width; j ++ {
			for k := 0; k < height; k++ {
				var value int
				if _, err := fmt.Scanf("%d", &value); err != nil {
					k--
					continue
				}
				game.setField(j, k, value == 1)
			}
		}
		res := game.moves()
		if res & 1 == 0 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}

package main

import (
	"fmt"
)
type Game struct {
	board  []bool
	Width  int
	Height int
}

func MakeGame(width, height int) Game {
	return Game{
		make([]bool, width * height),
		width,
		height,
	}
}
func (g *Game) setField(x,y int, value bool) {
	g.board[x + y * g.Width] = value
}
func (g Game) Board(x, y int) bool {
	if x > g.Width {
		fmt.Printf("!!Got x: %v that is greater than width: %v\n", x, g.Width)
	}
	return g.board[x + y * g.Width]
}

func (g Game) freeRows() (res int) {
	for x := 0; x < g.Width; x ++ {
		current := false
		for y := 0; y < g.Height; y++ {
			fmt.Printf("%v ", g.Board(x,y))
			current = current || g.Board(x,y)
		}
		fmt.Println()
		if current {
			res += 1
		}
	}
	return g.Width - res
}

func (g Game) freeCols() (res int) {
	for y := 0; y < g.Height; y++ {
		current := false
		for x := 0; x < g.Width; x ++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Height - res
}

func (g Game) moves() int {
	cols, rows := g.freeCols(), g.freeRows()
	fmt.Printf("\n got %v %v\n", cols, rows)
	if cols > rows {
		return rows
	} else {
		return cols
	}
}

func main() {
	testcases := 0
	_, _ = fmt.Scanf("%d", &testcases)
	for i := 0; i < testcases; i++ {
		var width, height int
		if _, err := fmt.Scanf("%d %d", &width, &height); err != nil {
			testcases --
			continue
		}
		game := MakeGame(width, height)
		for j := 0; j < width; j ++ {
			for k := 0; k < height; k++ {
				var value int
				fmt.Scanf("%d", &value)
				game.setField(j, k, value == 1)
			}
		}
		res := game.moves()
		fmt.Printf("moves %v\n", res)
		if res & 1 == 0 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}

package main

import (
	"fmt"
)
type Game struct {
	board  []bool
	Width  int
	Height int
}

func MakeGame(width, height int) Game {
	return Game{
		make([]bool, width * height),
		width,
		height,
	}
}
func (g *Game) setField(x,y int, value bool) {
	g.board[x + y * g.Width] = value
}
func (g Game) Board(x, y int) bool {
	//if x > g.Width {
	//	fmt.Printf("!!Got x: %v that is greater than width: %v\n", x, g.Width)
	//}
	return g.board[x + y * g.Width]
}

func (g Game) freeRows() (res int) {
	for x := 0; x < g.Width; x ++ {
		current := false
		for y := 0; y < g.Height; y++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Width - res
}

func (g Game) freeCols() (res int) {
	for y := 0; y < g.Height; y++ {
		current := false
		for x := 0; x < g.Width; x ++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Height - res
}

func (g Game) moves() int {
	cols, rows := g.freeCols(), g.freeRows()
	if cols > rows {
		return rows
	} else {
		return cols
	}
}

func main() {
	testcases := 0
	_, _ = fmt.Scanf("%d", &testcases)
	for i := 0; i < testcases; i++ {
		var width, height int
		if _, err := fmt.Scanf("%d %d", &width, &height); err != nil {
			testcases --
			continue
		}
		game := MakeGame(width, height)
		for j := 0; j < width; j ++ {
			for k := 0; k < height; k++ {
				var value int
				fmt.Scanf("%d", &value)
				game.setField(j, k, value == 1)
			}
		}
		res := game.moves()
		if res & 1 == 0 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}

package main

import (
	"fmt"
)
type Game struct {
	board  []bool
	Width  int
	Height int
}

func MakeGame(width, height int) Game {
	return Game{
		make([]bool, width * height),
		width,
		height,
	}
}
func (g *Game) setField(x,y int, value bool) {
	g.board[x + y * g.Width] = value
}
func (g Game) Board(x, y int) bool {
	if x > g.Width {
		fmt.Printf("!!Got x: %v that is greater than width: %v\n", x, g.Width)
	}
	return g.board[x + y * g.Width]
}

func (g Game) freeRows() (res int) {
	for x := 0; x < g.Width; x ++ {
		current := false
		for y := 0; y < g.Height; y++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Width - res
}

func (g Game) freeCols() (res int) {
	for y := 0; y < g.Height; y++ {
		current := false
		for x := 0; x < g.Width; x ++ {
			current = current || g.Board(x,y)
		}
		if current {
			res += 1
		}
	}
	return g.Height - res
}

func (g Game) moves() int {
	cols, rows := g.freeCols(), g.freeRows()
	if cols > rows {
		return rows
	} else {
		return cols
	}
}

func main() {
	testcases := 0
	fmt.Scanf("%d", &testcases)
	for i := 0; i < testcases; i++ {
		var width, height int
		fmt.Scanf("%d %d", &width, &height)
		game := MakeGame(width, height)
		for j := 0; j < width; j ++ {
			for k := 0; k < height; k++ {
				var value int
				fmt.Scanf("%d", &value)
				game.setField(j, k, value == 1)
			}
		}
		res := game.moves()
		if res & 1 == 0 {
			fmt.Println("Vivek")
		} else {
			fmt.Println("Ashish")
		}
	}
}


The sequence $$$a$$$ is sent over the network as follows:  sequence $$$a$$$ is split into segments (each element of the sequence belongs to exactly one segment, each segment is a group of consecutive elements of sequence);  for each segment, its length is written next to it, either to the left of it or to the right of it;  the resulting sequence $$$b$$$ is sent over the network. For example, we needed to send the sequence $$$a = [1, 2, 3, 1, 2, 3]$$$. Suppose it was split into segments as follows: $$$[\color{red}{1}] + [\color{blue}{2, 3, 1}] + [\color{green}{2, 3}]$$$. Then we could have the following sequences:   $$$b = [1, \color{red}{1}, 3, \color{blue}{2, 3, 1}, \color{green}{2, 3}, 2]$$$,  $$$b = [\color{red}{1}, 1, 3, \color{blue}{2, 3, 1}, 2, \color{green}{2, 3}]$$$,  $$$b = [\color{red}{1}, 1, \color{blue}{2, 3, 1}, 3, 2, \color{green}{2, 3}]$$$,  $$$b = [\color{red}{1}, 1,\color{blue}{2, 3, 1}, 3, \color{green}{2, 3}, 2]$$$. If a different segmentation had been used, the sent sequence might have been different.The sequence $$$b$$$ is given. Could the sequence $$$b$$$ be sent over the network? In other words, is there such a sequence $$$a$$$ that converting $$$a$$$ to send it over the network could result in a sequence $$$b$$$?

The first line of input data contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Each test case consists of two lines. The first line of the test case contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of the sequence $$$b$$$. The second line of test case contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le 10^9$$$) — the sequence $$$b$$$ itself. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case print on a separate line:   YES if sequence $$$b$$$ could be sent over the network, that is, if sequence $$$b$$$ could be obtained from some sequence $$$a$$$ to send $$$a$$$ over the network.  NO otherwise.  You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as positive response).

NoteIn the first case, the sequence $$$b$$$ could be obtained from the sequence $$$a = [1, 2, 3, 1, 2, 3]$$$ with the following partition: $$$[\color{red}{1}] + [\color{blue}{2, 3, 1}] + [\color{green}{2, 3}]$$$. The sequence $$$b$$$: $$$[\color{red}{1}, 1, \color{blue}{2, 3, 1}, 3, 2, \color{green}{2, 3}]$$$.In the second case, the sequence $$$b$$$ could be obtained from the sequence $$$a = [12, 7, 5]$$$ with the following partition: $$$[\color{red}{12}] + [\color{green}{7, 5}]$$$. The sequence $$$b$$$: $$$[\color{red}{12}, 1, 2, \color{green}{7, 5}]$$$.In the third case, the sequence $$$b$$$ could be obtained from the sequence $$$a = [7, 8, 9, 10, 3]$$$ with the following partition: $$$[\color{red}{7, 8, 9, 10, 3}]$$$. The sequence $$$b$$$: $$$[5, \color{red}{7, 8, 9, 10, 3}]$$$.In the fourth case, there is no sequence $$$a$$$ such that changing $$$a$$$ for transmission over the network could produce a sequence $$$b$$$.

package main

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

var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func solve() string {
	var n int
	fmt.Fscan(in, &n)
	v := make([]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &v[i])
	}

	dp := make([]bool, n+1)
	dp[0] = true

	for i := 1; i <= n; i++ {
		if i+v[i] <= n && dp[i-1] {
			dp[i+v[i]] = true
		}
		if i-v[i]-1 >= 0 && dp[i-v[i]-1] {
			dp[i] = true
		}
	}

	if dp[n] {
		return "YES"
	}
	return "NO"
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

// util functions
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

func makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

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)

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

		dp := make([]bool, n+1)
		dp[0] = true

		for i := range b {
			if dp[i] && i+b[i] < n {
				dp[i+b[i]+1] = true
			}
			if i-b[i] >= 0 && dp[i-b[i]] {
				dp[i+1] = true
			}
		}

		if dp[n] {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}

}

package main

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

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

func e1740(_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

	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
		}

		d := make([]map[int]bool, n)
		for i := 0; i < n; i++ {
			d[i] = map[int]bool{}
			if a[i]+i < n {
				d[i][a[i]+i] = true
			}
		}
		for i := n - 1; i >= 0; i-- {
			if i-a[i] >= 0 {
				d[i-a[i]][i] = true
			}
		}
		//Fprintln(out, d)

		vis := make([]bool, n)
		var dfs func(i int) bool
		dfs = func(i int) bool {
			if vis[i]  {
				return false
			}
			for x, _:= range d[i] {
				if x == n-1 {
					return true
				}
				if dfs(x+1) {
					return true
				}
			}

			vis[i] = true
			return false
		}

		bl := dfs(0)
		ans := "YES"
		if !bl {
			ans = "NO"
		}

		Fprintln(out, ans)
	}
}

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 solve() {
	var n int
	scanf("%d\n", &n)
	a := make([]int, n+1)
	for i:=1; i<=n; i++ {
		scanf("%d ", &a[i])
	}
	scanf("\n")

	// dpFront := make([]bool, n+1)
	// dpBack := make([]bool, n+1)
	// dpFront[0] = true
	// dpBack[0] = true

	dp := make([]bool, n+1)
	dp[0] = true

	for i:=1; i<=n; i++ {
		if  dp[i-1] && i + a[i] <= n {
			dp[i+a[i]] = true
		}
		if i-a[i] >= 1 && dp[i-a[i]-1] {
			dp[i] = true
		}
	}

	if dp[n] {
		printf("YES\n")
		return
	}
	printf("NO\n")
}

func main() {
	defer writer.Flush()

	var T int
	scanf("%d\n", &T)
	for tt:=1; tt<=T; tt++ {
		solve()
	}
}

package main

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

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

func readInt() int {
	var i int
	fmt.Fscan(reader, &i)
	return i
}

func max(u, v int) int {
	if u < v {
		u = v
	}

	return u
}

func min(u, v int) int {
	if u > v {
		u = v
	}

	return u
}

func main(){
	defer writer.Flush()
	T := readInt()

	for ;T > 0; T-- {
		n := readInt()
		a := make([]int, n)
		dp := make([]bool, n + 1)
		for i := 0; i < n; i++ {
			a[i] = readInt()
		}
		mp := make(map[int] []int)
		dp[0] = true

		for i := 1; i <= n; i++ {
			if i >= a[i - 1] + 1 && dp[i - a[i-1] - 1]{
				dp[i] = true
			}
			_, found := mp[i + a[i-1]]
			if !found {
				mp[i + a[i-1]] = make([]int, 0)
			}
			candidates, found := mp[i]
			for _, candidate := range candidates {
				if dp[candidate - 1] {
					dp[i] = true
					break
				}
			}
			mp[i + a[i-1]] = append(mp[i + a[i-1]], i)
		}
		if dp[n] {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

const INF = 1000000000
const N = 2e5 + 5

func main() {
	sc.Buffer(make([]byte, 500000*1+1), 500000)
	sc.Split(bufio.ScanWords)

	T := nextInt()
	for T > 0 {
		T--
		n := nextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = nextInt()
		}
		f := make([]bool, n)
		for i := 0; i < n; i++ {
			if i-a[i] == 0 || (i-a[i]-1 >= 0 && f[i-a[i]-1]) {
				f[i] = true
			}
			if (i == 0 || f[i-1]) && i+a[i] < n {
				f[i+a[i]] = true
			}
		}
		// for i := 0; i < n; i++ {
		if f[n-1] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
		// }
		// fmt.Println()
	}
}

func max(args ...int) int {
	res := args[0]
	for _, v := range args {
		if v > res {
			res = v
		}
	}
	return res
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

package main

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

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([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}

		mm := make([]bool, n+1)
		mm[0] = true
		for i, v := range aa {
			if mm[i] && i+v+1 < n+1 {
				mm[i+v+1] = true
			}
			if i-v >= 0 && mm[i-v] {
				mm[i+1] = true
			}
		}
		if mm[n] {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}

	}
}

package main

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

const N int = 2e5 + 10

var dp [N][2]bool
var n, res int
var a [N]int

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

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

	var T int
	Fscan(in, &T)
	for ; T > 0; T-- {
		Fscan(in, &n)
		dp[0][0] = true
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			for j := 0; j < 2; j++ {
				dp[i][j] = false
			}
		}
		for i := 1; i <= n; i++ {
			if i+a[i] <= n && (dp[i - 1][0] || dp[i - 1][1]) {
				dp[i+a[i]][0] = true
			}
			if i-a[i] > 0 && (dp[i-a[i]-1][0] || dp[i-a[i]-1][1]) {
				dp[i][1] = true
			}
		}
// 		for i := 1; i <= n; i ++ {
// 			Fprintln(out, "i = ", i, " ", dp[i][0], dp[i][1])
// 		}
		if dp[n][0] || dp[n][1] {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}

	}

}

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

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

func max(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"
	"os"
	"sort"
	"strconv"
)

const cf = true

func solve() {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &arr[i])
	}
	dp := make([]bool, n+1)
	dp[0] = true
	good := func(i int) bool {
		if i > n || i < 0 {
			return false
		}
		return true
	}
	check := func(i int) bool {
		if !good(i) {
			return false
		}
		return dp[i]
	}
	for i := 1; i <= n; i++ {
		if check(i - arr[i] - 1) {
			dp[i] = true
		}
		if dp[i-1] && good(i+arr[i]) {
			dp[i+arr[i]] = true
		}
	}
	if dp[n] == true {
		fmt.Fprintln(out, "YES")
	} else {
		fmt.Fprintln(out, "NO")
	}
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

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)

		b := make([]int, n+1)
		for i := 1; i <= n; i++ { fmt.Fscan(r, &b[i]) }

		dp := make([]bool, n+1)
		dp[0] = true

		for i := 1; i <= n; i++ {
			if dp[i-1] && i+b[i] <= n {
				dp[i+b[i]] = true
			} else if i-b[i] > 0 && dp[i-b[i]-1] {
				dp[i] = true
			}
		}

		if dp[n] {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}

}

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)

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

		dp := make([]bool, n+1)
		dp[0] = true

		for i := range b {
			if dp[i] && i+b[i] < n {
				dp[i+b[i]+1] = true
			} else if i-b[i] >= 0 && dp[i-b[i]] {
				dp[i+1] = true
			}
		}

		if dp[n] {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}

}

package main

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

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

func e1740(_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

	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
		}

		d := make([]map[int]bool, n)
		for i := 0; i < n; i++ {
			d[i] = map[int]bool{}
			if a[i]+i < n {
				d[i][a[i]+i] = true
			}
		}
		for i := n - 1; i >= 0; i-- {
			if i-a[i] >= 0 {
				d[i-a[i]][i] = true
			}
		}

		vis := make([]bool, n)
		var dfs func(i int) bool
		dfs = func(i int) bool {
			if vis[i]  {
				return false
			}
			for x, _:= range d[i] {
				if x == n-1 {
					return true
				}
				if dfs(x) {
					return true
				}
			}

			vis[i] = true
			return false
		}

		bl := dfs(0)
		ans := "YES"
		if !bl {
			ans = "NO"
		}

		Fprintln(out, ans)
	}
}

package main

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

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

func e1740(_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

	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
		}

		d := make([][]int, n)
		for i := 0; i < n; i++ {
			if a[i]+i < n {
				d[i] = append(d[i], a[i]+i)
			}
		}
		for i := n - 1; i >= 0; i-- {
			if i-a[i] >= 0 {
				d[i-a[i]] = append(d[i-a[i]], i)
			}
		}

		vis := make([]int, n)
		var dfs func(i int) bool
		dfs = func(i int) bool {

			if vis[i] != 0 {
				return vis[i] == 1
			}
			for _, x:= range d[i] {
				if x == n-1 {
					return true
				}
				if dfs(x) {
					return true
				}
			}

			vis[i] = -1
			return false
		}

		bl := dfs(0)
		ans := "YES"
		if !bl {
			ans = "NO"
		}

		Fprintln(out, ans)
	}
}


Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$.    An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border).

The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position of the $$$i$$$-th grasshopper.

Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).

NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield.

package main

import "fmt"

func main() {
	var n, d, m int
	fmt.Scan(&n, &d, &m)
	x := make([]int, m)
	y := make([]int, m)
	on := make([]bool, m)
	for i := range x {
		fmt.Scan(&x[i], &y[i])
	}
	for i := range x {
		if y[i] <= x[i] + d && y[i] <= -x[i] + 2 * n - d && y[i] >= x[i] - d && y[i] >= -x[i] + d {
			on[i] = true
		} else {
			on[i] = false
		}
	}

	for _, one := range on {
		if one {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var n, d, m int8
	fmt.Scan(&n, &d, &m)
	x := make([]int8, m)
	y := make([]int8, m)
	on := make([]bool, m)
	for i := range x {
		fmt.Scan(&x[i], &y[i])
	}
	for i := range x {
		if y[i] <= x[i] + d && y[i] <= -x[i] + 2 * n - d && y[i] >= x[i] - d && y[i] >= -x[i] + d {
			on[i] = true
		} else {
			on[i] = false
		}
	}

	for _, one := range on {
		if one {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}


Igor the analyst fell asleep on the work and had a strange dream. In the dream his desk was crowded with computer mice, so he bought a mousetrap to catch them.The desk can be considered as an infinite plane, then the mousetrap is a rectangle which sides are parallel to the axes, and which opposite sides are located in points (x1, y1) and (x2, y2).Igor wants to catch all mice. Igor has analysed their behavior and discovered that each mouse is moving along a straight line with constant speed, the speed of the i-th mouse is equal to (vix, viy), that means that the x coordinate of the mouse increases by vix units per second, while the y coordinates increases by viy units. The mousetrap is open initially so that the mice are able to move freely on the desk. Igor can close the mousetrap at any moment catching all the mice that are strictly inside the mousetrap.Igor works a lot, so he is busy in the dream as well, and he asks you to write a program that by given mousetrap's coordinates, the initial coordinates of the mice and their speeds determines the earliest time moment in which he is able to catch all the mice. Please note that Igor can close the mousetrap only once.

The first line contains single integer n (1 ≤ n ≤ 100 000) — the number of computer mice on the desk. The second line contains four integers x1, y1, x2 and y2 (0 ≤ x1 ≤ x2 ≤ 100 000), (0 ≤ y1 ≤ y2 ≤ 100 000) — the coordinates of the opposite corners of the mousetrap. The next n lines contain the information about mice. The i-th of these lines contains four integers rix, riy, vix and viy, (0 ≤ rix, riy ≤ 100 000,  - 100 000 ≤ vix, viy ≤ 100 000), where (rix, riy) is the initial position of the mouse, and (vix, viy) is its speed.

In the only line print minimum possible non-negative number t such that if Igor closes the mousetrap at t seconds from the beginning, then all the mice are strictly inside the mousetrap. If there is no such t, print -1. Your answer is considered correct if its absolute or relative error doesn't exceed 10 - 6.  Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if .

NoteHere is a picture of the first samplePoints A, B, C, D - start mice positions, segments are their paths.Then, at first time when all mice will be in rectangle it will be looks like this:Here is a picture of the second samplePoints A, D, B will never enter rectangle.

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

func readInt() int64 {
	var n int64
	fmt.Fscan(in, &n)
	return n
}

type xy struct {
	x, y int64
}

type mouse struct {
	r, v xy
}

const inf = 1e10

func main() {
	n := int(readInt())
	rec := [2]xy{{readInt(), readInt()}, {readInt(), readInt()}}
	lo := 0.
	hi := inf
	update := func(st, en float64) {
		if st > lo {
			lo = st
		}
		if en < hi {
			hi = en
		}
	}
	for i := 0; i < n; i++ {
		m := mouse{xy{readInt(), readInt()}, xy{readInt(), readInt()}}
		update(tRange(m.r.x, m.v.x, rec[0].x, rec[1].x))
		update(tRange(m.r.y, m.v.y, rec[0].y, rec[1].y))
	}

	if lo < hi {
		fmt.Printf("%.9f\n", lo)
	} else {
		fmt.Println(-1)
	}
}

func tRange(r, v, min, max int64) (st, en float64) {
	if r <= min {
		if v <= 0 {
			return inf, 0
		}
		st = float64(min-r) / float64(v)
	} else if r >= max {
		if v >= 0 {
			return inf, 0
		}
		st = float64(r-max) / float64(-v)
	}

	if v < 0 {
		en = float64(r-min) / float64(-v)
	} else if v > 0 {
		en = float64(max-r) / float64(v)
	} else {
		en = inf
	}
	return
}

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

func readInt() int64 {
	var n int64
	fmt.Fscan(in, &n)
	return n
}

type xy struct {
	x, y int64
}

type mouse struct {
	r, v xy
}

const inf = 1e10

func main() {
	n := int(readInt())
	rec := [2]xy{{readInt(), readInt()}, {readInt(), readInt()}}
	lo := 0.
	hi := inf
	update := func(st, en float64) {
		if st > lo {
			lo = st
		}
		if en < hi {
			hi = en
		}
	}
	for i := 0; i < n; i++ {
		m := mouse{xy{readInt(), readInt()}, xy{readInt(), readInt()}}
		update(tRange(m.r.x, m.v.x, rec[0].x, rec[1].x))
		update(tRange(m.r.y, m.v.y, rec[0].y, rec[1].y))
	}

	if lo+1e-8 < hi {
		fmt.Printf("%.9f\n", lo)
	} else {
		fmt.Println(-1)
	}
}

func tRange(r, v, min, max int64) (st, en float64) {
	if r <= min {
		if v <= 0 {
			return inf, 0
		}
		st = float64(min-r) / float64(v)
	} else if r >= max {
		if v >= 0 {
			return inf, 0
		}
		st = float64(r-max) / float64(-v)
	}

	if v < 0 {
		en = float64(r-min) / float64(-v)
	} else if v > 0 {
		en = float64(max-r) / float64(v)
	}
	return
}

package main

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

var in = bufio.NewScanner(os.Stdin)

func readInt() int64 {
	if !in.Scan() {
		panic(in.Err())
	}
	res := int64(0)
	mul := int64(1)
	for _, b := range in.Bytes() {
		if b == '-' {
			mul *= -1
			continue
		}
		res = res*10 + int64(b-'0')
	}
	return mul * res
}

type mouse struct {
	r, v [2]int64
}

func intersect(m mouse, a, b [2]int64) float64 {
	a[0] -= m.r[0]
	b[0] -= m.r[0]
	a[1] -= m.r[1]
	b[1] -= m.r[1]
	if a[0] == b[0] {
		if m.v[0] == 0 {
			return -1
		}
		t := float64(a[0]) / float64(m.v[0])
		if t < 0 {
			return -1
		}
		y := float64(m.v[1]) * t
		if float64(a[1]) >= y && y >= float64(b[1]) || float64(b[1]) >= y && y >= float64(a[1]) {
			return t
		}
		return -1
	} else {
		if m.v[1] == 0 {
			return -1
		}
		t := float64(a[1]) / float64(m.v[1])
		if t < 0 {
			return -1
		}
		x := float64(m.v[0]) * t
		if float64(a[0]) >= x && x >= float64(b[0]) || float64(b[0]) >= x && x >= float64(a[0]) {
			return t
		}
		return -1
	}
}

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

	n := readInt()
	rec := [2][2]int64{{readInt(), readInt()}, {readInt(), readInt()}}
	mice := make([][2]float64, n)
	for i := range mice {
		m := mouse{[2]int64{readInt(), readInt()}, [2]int64{readInt(), readInt()}}
		if m.v[0] == 0 && m.v[1] == 0 {
			if m.r[0] > rec[0][0] && m.r[0] < rec[1][0] && m.r[1] > rec[0][1] && m.r[1] < rec[1][1] {
				mice[i] = [2]float64{0, 1e10}
				continue
			} else {
				fmt.Println(-1)
				return
			}
		}
		t := []float64{
			intersect(m, rec[0], [2]int64{rec[0][0], rec[1][1]}),
			intersect(m, [2]int64{rec[0][0], rec[1][1]}, rec[1]),
			intersect(m, rec[1], [2]int64{rec[1][0], rec[0][1]}),
			intersect(m, [2]int64{rec[1][0], rec[0][1]}, rec[0]),
		}
		sort.Float64s(t)
		for len(t) > 0 && t[0] == -1 {
			t = t[1:]
		}
		if len(t) < 2 {
			fmt.Println(-1)
			return
		}
		mice[i] = [2]float64{t[0], t[len(t)-1]}
	}

	max0 := mice[0][0]
	min1 := mice[0][1]
	for _, m := range mice[1:] {
		if max0 < m[0] {
			max0 = m[0]
		}
		if min1 > m[1] {
			min1 = m[1]
		}
	}
	if max0 < min1 {
		fmt.Printf("%.9f\n", max0)
	} else {
		fmt.Println(-1)
	}
}

package main

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

var in = bufio.NewScanner(os.Stdin)

func readInt() int64 {
	if !in.Scan() {
		panic(in.Err())
	}
	res := int64(0)
	mul := int64(1)
	for _, b := range in.Bytes() {
		if b == '-' {
			mul *= -1
			continue
		}
		res = res*10 + int64(b-'0')
	}
	return mul * res
}

type mouse struct {
	r, v [2]int64
}

func intersect(m mouse, a, b [2]int64) float64 {
	a[0] -= m.r[0]
	b[0] -= m.r[0]
	a[1] -= m.r[1]
	b[1] -= m.r[1]
	if a[0] == b[0] {
		if m.v[0] == 0 {
			return -1
		}
		t := float64(a[0]) / float64(m.v[0])
		if t < 0 {
			return -1
		}
		y := float64(m.v[1]) * t
		if float64(a[1]) > y && y > float64(b[1]) || float64(b[1]) > y && y > float64(a[1]) {
			return t
		}
		if float64(a[1]) >= y && y >= float64(b[1]) || float64(b[1]) >= y && y >= float64(a[1]) {
			if m.v[0] != 0 && m.v[1] != 0 {
				return t
			}
		}
		return -1
	} else {
		if m.v[1] == 0 {
			return -1
		}
		t := float64(a[1]) / float64(m.v[1])
		if t < 0 {
			return -1
		}
		x := float64(m.v[0]) * t
		if float64(a[0]) > x && x > float64(b[0]) || float64(b[0]) > x && x > float64(a[0]) {
			return t
		}
		if float64(a[0]) >= x && x >= float64(b[0]) || float64(b[0]) >= x && x >= float64(a[0]) {
			if m.v[0] != 0 && m.v[1] != 0 {
				return t
			}
		}
		return -1
	}
}

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

	n := readInt()
	rec := [2][2]int64{{readInt(), readInt()}, {readInt(), readInt()}}
	mice := make([][2]float64, n)
	for i := range mice {
		m := mouse{[2]int64{readInt(), readInt()}, [2]int64{readInt(), readInt()}}
		if m.v[0] == 0 && m.v[1] == 0 {
			if m.r[0] > rec[0][0] && m.r[0] < rec[1][0] && m.r[1] > rec[0][1] && m.r[1] < rec[1][1] {
				mice[i] = [2]float64{0, 1e10}
				continue
			} else {
				fmt.Println(-1)
				return
			}
		}
		t := []float64{
			intersect(m, rec[0], [2]int64{rec[0][0], rec[1][1]}),
			intersect(m, [2]int64{rec[0][0], rec[1][1]}, rec[1]),
			intersect(m, rec[1], [2]int64{rec[1][0], rec[0][1]}),
			intersect(m, [2]int64{rec[1][0], rec[0][1]}, rec[0]),
		}
		sort.Float64s(t)
		for len(t) > 0 && t[0] == -1 {
			t = t[1:]
		}
		if len(t) < 2 {
			fmt.Println(-1)
			return
		}
		mice[i] = [2]float64{t[0], t[len(t)-1]}
	}

	max0 := mice[0][0]
	min1 := mice[0][1]
	for _, m := range mice[1:] {
		if max0 < m[0] {
			max0 = m[0]
		}
		if min1 > m[1] {
			min1 = m[1]
		}
	}
	if max0 < min1 {
		fmt.Printf("%.9f\n", max0)
	} else {
		fmt.Println(-1)
	}
}

package main

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

var in = bufio.NewScanner(os.Stdin)

func readInt() int64 {
	if !in.Scan() {
		panic(in.Err())
	}
	res := int64(0)
	mul := int64(1)
	for _, b := range in.Bytes() {
		if b == '-' {
			mul *= -1
			continue
		}
		res = res*10 + int64(b-'0')
	}
	return mul * res
}

type mouse struct {
	r, v [2]int64
}

func intersect(m mouse, a, b [2]int64) float64 {
	a[0] -= m.r[0]
	b[0] -= m.r[0]
	a[1] -= m.r[1]
	b[1] -= m.r[1]
	if a[0] == b[0] {
		if m.v[0] == 0 {
			return -1
		}
		t := float64(a[0]) / float64(m.v[0])
		if t < 0 {
			return -1
		}
		y := float64(m.v[1]) * t
		if float64(a[1]) >= y && y >= float64(b[1]) || float64(b[1]) >= y && y >= float64(a[1]) {
			return t
		}
		return -1
	} else {
		if m.v[1] == 0 {
			return -1
		}
		t := float64(a[1]) / float64(m.v[1])
		if t < 0 {
			return -1
		}
		x := float64(m.v[0]) * t
		if float64(a[0]) >= x && x >= float64(b[0]) || float64(b[0]) >= x && x >= float64(a[0]) {
			return t
		}
		return -1
	}
}

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

	n := readInt()
	rec := [2][2]int64{{readInt(), readInt()}, {readInt(), readInt()}}
	mice := make([][2]float64, n)
	for i := range mice {
		m := mouse{[2]int64{readInt(), readInt()}, [2]int64{readInt(), readInt()}}
		if m.v[0] == 0 && m.v[1] == 0 {
			if m.r[0] > rec[0][0] && m.r[0] < rec[1][0] && m.r[1] > rec[0][1] && m.r[1] < rec[1][1] {
				mice[i] = [2]float64{-1, 1e10}
				continue
			} else {
				fmt.Println(-1)
				return
			}
		}
		t := []float64{
			intersect(m, rec[0], [2]int64{rec[0][0], rec[1][1]}),
			intersect(m, [2]int64{rec[0][0], rec[1][1]}, rec[1]),
			intersect(m, rec[1], [2]int64{rec[1][0], rec[0][1]}),
			intersect(m, [2]int64{rec[1][0], rec[0][1]}, rec[0]),
		}
		sort.Float64s(t)
		for len(t) > 0 && t[0] == -1 {
			t = t[1:]
		}
		if len(t) < 2 {
			fmt.Println(-1)
			return
		}
		mice[i] = [2]float64{t[0], t[len(t)-1]}
	}

	max0 := mice[0][0]
	min1 := mice[0][1]
	for _, m := range mice[1:] {
		if max0 < m[0] {
			max0 = m[0]
		}
		if min1 > m[1] {
			min1 = m[1]
		}
	}
	if max0 < min1 {
		fmt.Printf("%.9f\n", max0)
	} else {
		fmt.Println(-1)
	}
}

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

func readInt() int64 {
	var n int64
	fmt.Fscan(in, &n)
	return n
}

type xy struct {
	x, y int64
}

type mouse struct {
	r, v xy
}

const inf = 1e10

func main() {
	n := int(readInt())
	rec := [2]xy{{readInt(), readInt()}, {readInt(), readInt()}}
	lo := 0.
	hi := inf
	update := func(st, en float64) {
		if st > lo {
			lo = st
		}
		if en < hi {
			hi = en
		}
	}
	for i := 0; i < n; i++ {
		m := mouse{xy{readInt(), readInt()}, xy{readInt(), readInt()}}
		update(tRange(m.r.x, m.v.x, rec[0].x, rec[1].x))
		update(tRange(m.r.y, m.v.y, rec[0].y, rec[1].y))
	}

	if lo+1e-8 < hi {
		fmt.Printf("%.9f\n", lo)
	} else {
		fmt.Println(-1)
	}
}

func tRange(r, v, min, max int64) (st, en float64) {
	if r <= min {
		if v <= 0 {
			return inf, 0
		}
		st = float64(min-r) / float64(v)
	} else if r >= max {
		if v >= 0 {
			return inf, 0
		}
		st = float64(r-max) / float64(-v)
	}

	if v < 0 {
		en = float64(r-min) / float64(-v)
	} else if v > 0 {
		en = float64(max-r) / float64(v)
	} else {
		en = inf
	}
	return
}


You are given an integer $$$n$$$ and an array $$$a_1,a_2,\ldots,a_n$$$.In one operation, you can choose an index $$$i$$$ ($$$1 \le i \lt n$$$) for which $$$a_i \neq a_{i+1}$$$ and delete both $$$a_i$$$ and $$$a_{i+1}$$$ from the array. After deleting $$$a_i$$$ and $$$a_{i+1}$$$, the remaining parts of the array are concatenated.For example, if $$$a=[1,4,3,3,6,2]$$$, then after performing an operation with $$$i=2$$$, the resulting array will be $$$[1,3,6,2]$$$.What is the maximum possible length of an array of equal elements obtainable from $$$a$$$ by performing several (perhaps none) of the aforementioned operations?

Each test contains multiple test cases. The first line of input contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The following lines contain the descriptions of the test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 5000$$$) — the length of array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \le a_i \le n$$$) — the elements of array $$$a$$$. It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$10\,000$$$.

For each testcase, print a single integer, the maximum possible length of an array of equal elements obtainable from $$$a$$$ by performing a sequence of operations.

NoteFor the first testcase, an optimal sequence of operations would be: $$$[1,2,3,2,1,3,3] \rightarrow [3,2,1,3,3] \rightarrow [3,3,3]$$$.For the second testcase, all elements in the array are already equal.For the third testcase, the only possible sequence of operations is: $$$[1,1,1,2,2,2] \rightarrow [1,1,2,2] \rightarrow [1,2] \rightarrow []$$$. Note that, according to the statement, the elements deleted at each step must be different.For the fourth testcase, the optimal sequence of operations is: $$$[1,1,2,2,3,3,1,1] \rightarrow [1,1,2,3,1,1] \rightarrow [1,1,1,1]$$$.For the fifth testcase, one possible reachable array of two equal elements is $$$[4,4]$$$.

package main

import "fmt"

func solve(n int, arr []int) int {
	for i := 0; i < n; i++ {
		arr[i] -= 1
	}

	removable := make([][]bool, n+1)
	for r := 0; r <= n; r++ {
		removable[r] = make([]bool, r+1)
	}
	var count []int
	var max_count int

	for l := 0; l <= n; l++ {
		count = make([]int, n)
		for v := 0; v < n; v++ {
			count[v] = 0
		}
		max_count = 0

		removable[l][l] = true
		for r := l + 1; r <= n; r++ {
			value := arr[r-1]
			count[value] += 1
			if max_count < count[value] {
				max_count = count[value]
			}

			length := r - l
			if length%2 == 0 && 2*max_count <= length {
				removable[r][l] = true
			}
		}
	}

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

	update_best := func(r int, value int) {
		for l := r; l >= 0; l -= 2 {
			if removable[r][l] && (l == 0 || arr[l-1] == value) {
				var sub_result int
				if l == 0 {
					sub_result = 1
				} else if best[l-1] < 0 {
					continue
				} else {
					sub_result = best[l-1] + 1
				}
				if best[r] == -1 || best[r] < sub_result {
					best[r] = sub_result
				}
			}
		}
	}

	for r := 0; r < n; r++ {
		update_best(r, arr[r])
	}
	for v := 0; v < n; v++ {
		update_best(n, v)
	}

	return best[n] - 1
}

func main() {
	var T int
	fmt.Scan(&T)
	for i := 0; i < T; i++ {
		var n int
		fmt.Scan(&n)
		var arr = make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Scan(&arr[j])
		}
		fmt.Println(solve(n, arr))
	}
}