CQXYM found a rectangle $$$A$$$ of size $$$n \times m$$$. There are $$$n$$$ rows and $$$m$$$ columns of blocks. Each block of the rectangle is an obsidian block or empty. CQXYM can change an obsidian block to an empty block or an empty block to an obsidian block in one operation.A rectangle $$$M$$$ size of $$$a \times b$$$ is called a portal if and only if it satisfies the following conditions:  $$$a \geq 5,b \geq 4$$$.  For all $$$1 < x < a$$$, blocks $$$M_{x,1}$$$ and $$$M_{x,b}$$$ are obsidian blocks.  For all $$$1 < x < b$$$, blocks $$$M_{1,x}$$$ and $$$M_{a,x}$$$ are obsidian blocks.  For all $$$1<x<a,1<y<b$$$, block $$$M_{x,y}$$$ is an empty block.  $$$M_{1, 1}, M_{1, b}, M_{a, 1}, M_{a, b}$$$ can be any type.  Note that the there must be $$$a$$$ rows and $$$b$$$ columns, not $$$b$$$ rows and $$$a$$$ columns.Note that corners can be any typeCQXYM wants to know the minimum number of operations he needs to make at least one sub-rectangle a portal.

The first line contains an integer $$$t$$$ ($$$t \geq 1$$$), which is the number of test cases. For each test case, the first line contains two integers $$$n$$$ and $$$m$$$ ($$$5 \le n \le 400$$$, $$$4 \le m \le 400$$$).  Then $$$n$$$ lines follow, each line contains $$$m$$$ characters $$$0$$$ or $$$1$$$. If the $$$j$$$-th character of $$$i$$$-th line is $$$0$$$, block $$$A_{i,j}$$$ is an empty block. Otherwise, block $$$A_{i,j}$$$ is an obsidian block. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$400$$$. It is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$400$$$.

Output $$$t$$$ answers, and each answer in a line.

NoteIn the first test case, the final portal is like this:11101001100110010111

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{}) {
	suc, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		fmt.Println(suc, err)
	}
}

const maxn = 409

var sum [maxn][maxn]int
var f [maxn]int

func GetSum(lx, ly, rx, ry int) int {
	return sum[rx][ry] - sum[rx][ly-1] - sum[lx-1][ry] + sum[lx-1][ly-1]
}

func main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	//printf("%d\n", t)
	for ; t > 0; t-- {
		//for i := 0; i < maxn; i++ {
		//	f[i] = 0
		//	for j := 0; j < maxn; j++ {
		//		sum[i][j] = 0
		//	}
		//}
		var n, m int
		ans := 99
		scanf("%d %d\n", &n, &m)
		for i := 1; i <= n; i++ {
			var s string
			scanf("%s\n", &s)
			for k, c := range s {
				if '1' == c {
					sum[i][k+1] = 1
				} else {
					sum[i][k+1] = 0
				}
			}
		}
		for i := 1; i <= n; i++ {
			for j := 1; j <= m; j++ {
				sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1]
				//fmt.Printf("%d ", sum[i][j])
			}
			//fmt.Println()
		}
		for i := 1; i <= n; i++ {
			for j := i + 4; j <= n; j++ {
				for k := 4; k <= m; k++ {
					f[k] = GetSum(i+1, 1, j-1, k-1) - GetSum(i, 1, i, k-1) - GetSum(j, 1, j, k-1) - GetSum(i+1, k, j-1, k) + (k << 1) + j - i - 3
					//fmt.Printf("f[%d] = %d\n", k, f[k])
				}
				for k := m - 1; k != 3; k-- {
					if f[k+1] < f[k] {
						f[k] = f[k+1]
					}
				}
				for k := 1; k != m-2; k++ {
					cur := f[k+3] - GetSum(i+1, 1, j-1, k) + GetSum(i, 1, i, k) + GetSum(j, 1, j, k) - GetSum(i+1, k, j-1, k) - (k << 1) + j - i - 1
					//fmt.Printf("%d %d %d %d\n", GetSum(i+1, 1, j-1, k), GetSum(i, 1, i, k), GetSum(j, 1, j, k), GetSum(i+1, k, j-1, k))
					//fmt.Printf("%d %d %d\n", k, f[k+3], cur)

					if cur < ans {
						ans = cur
					}
				}
			}
		}
		printf("%d\n", ans)
		//fmt.Println(n, m)
		//for i := 1; i <= n; i++ {
		//	for j := 1; j <= m; j++ {
		//		fmt.Printf("%d ", sum[i][j])
		//	}
		//	fmt.Println()
		//}
	}
}

/*
2
5 4
1000
0000
0110
0000
0001
9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000

*/

/*
1
9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000

*/

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1580A(_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)
		a := make([]string, n)
		sum := make([][]int, n+1)
		sum[0] = make([]int, m+1)
		for i := range a {
			Fscan(in, &a[i])
			sum[i+1] = make([]int, m+1)
			for j, v := range a[i] {
				sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j] + int(v&1)
			}
		}
		query := func(r1, c1, r2, c2 int) int { r2++; c2++; return sum[r2][c2] - sum[r2][c1] - sum[r1][c2] + sum[r1][c1] }

		const minR, minC, inf = 5, 4, 99
		ans := inf
		for i := minR - 1; i < n; i++ {
			for j := i - minR + 1; j >= 0; j-- {
				mi := inf
				for k := minC - 1; k < m; k++ {
					mi = query(j+1, k-1, i-1, k-1) + int((a[j][k-1]&1^1)+(a[i][k-1]&1^1)) + // 第 k-1 列
						min(mi, query(j+1, k-minC+2, i-1, k-2)+ // 第 k-2 至 k-minC+2 列的中间部分
							minC-3-query(j, k-minC+2, j, k-2)+ // 的第 j 行
							minC-3-query(i, k-minC+2, i, k-2)+ // 的第 i 行
							i-j-1-query(j+1, k-minC+1, i-1, k-minC+1)) // 第 k-minC+1 列（去掉两角）
					ans = min(ans, mi+i-j-1-query(j+1, k, i-1, k))     // 第 k 列（去掉两角）
				}
			}
		}
		Fprintln(out, ans)
	}
}

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

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1580A(_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)
		a := make([]string, n)
		sum := make([][]int, n+1)
		sum[0] = make([]int, m+1)
		for i := range a {
			Fscan(in, &a[i])
			sum[i+1] = make([]int, m+1)
			for j, v := range a[i] {
				sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j] + int(v&1)
			}
		}
		query := func(r1, c1, r2, c2 int) int {
			r2++
			c2++
			return sum[r2][c2] - sum[r2][c1] - sum[r1][c2] + sum[r1][c1]
		}

		const minR, minC, inf = 5, 4, 99
		ans := inf
		for i := minR - 1; i < n; i++ {
			for j := i - minR + 1; j >= 0; j-- {
				mi := inf
				for k := minC - 1; k < m; k++ {
					mi = query(j+1, k-1, i-1, k-1) + int((a[j][k-1]&1^1)+(a[i][k-1]&1^1)) +
						min(mi, query(j+1, k-minC+2, i-1, k-2)+
							minC-3-query(j, k-minC+2, j, k-2)+
							minC-3-query(i, k-minC+2, i, k-2)+
							i-j-1-query(j+1, k-3, i-1, k-3))
					ans = min(ans, mi+i-j-1-query(j+1, k, i-1, k))
				}
			}
		}
		Fprintln(out, ans)
	}
}

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

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1580A(_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)
		a := make([]string, n)
		sum := make([][]int, n+1)
		sum[0] = make([]int, m+1)
		for i := range a {
			Fscan(in, &a[i])
			sum[i+1] = make([]int, m+1)
			for j, v := range a[i] {
				sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j] + int(v&1)
			}
		}
		query := func(r1, c1, r2, c2 int) int {
			r2++
			c2++
			return sum[r2][c2] - sum[r2][c1] - sum[r1][c2] + sum[r1][c1]
		}

		const minR, minC, inf = 5, 4, 99
		ans := inf
		for i := minR - 1; i < n; i++ {
			for j := i - minR + 1; j >= 0; j-- {
				mi := inf
				for k := minC - 1; k < m; k++ {
					mi = query(j+1, k-1, i-1, k-1) + int((a[j][k-1]&1^1)+(a[i][k-1]&1^1)) +
						min(mi, query(j+1, k-2, i-1, k-2)+int((a[j][k-2]&1^1)+(a[i][k-2]&1^1))+i-j-1-query(j+1, k-3, i-1, k-3))
					ans = min(ans, mi+i-j-1-query(j+1, k, i-1, k))
				}
			}
		}
		Fprintln(out, ans)
	}
}

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

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

package main

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

const maxn = 409

var sum [maxn][maxn]int
var f [maxn]int

func GetSum(lx, ly, rx, ry int) int {
	return sum[rx][ry] - sum[rx][ly-1] - sum[lx-1][ry] + sum[lx-1][ly-1]
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	read_int := func() (x int) {
		c, _ := in.ReadByte()
		for ; c < '0'; c, _ = in.ReadByte() {
		}
		for ; c >= '0'; c, _ = in.ReadByte() {
			x = x*10 + int(c-'0')
		}
		return
	}
	t = read_int()
	for ; t > 0; t-- {
		for i := 0; i < maxn; i++ {
			f[i] = 0
			for j := 0; j < maxn; j++ {
				sum[i][j] = 0
			}
		}
		var n, m int
		ans := 99
		n = read_int()
		m = read_int()
		for i := 1; i <= n; i++ {
			s, _ := in.ReadString('\n')
			for k, c := range s {
				if '1' == c {
					sum[i][k+1] = 1
				} else {
					sum[i][k+1] = 0
				}
			}
		}
		for i := 1; i <= n; i++ {
			for j := 1; j <= m; j++ {
				sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1]
				fmt.Printf("%d ", sum[i][j])
			}
			fmt.Println()
		}
		for i := 1; i <= n; i++ {
			for j := i + 4; j <= n; j++ {
				for k := 4; k <= m; k++ {
					f[k] = GetSum(i+1, 1, j-1, k-1) - GetSum(i, 1, i, k-1) - GetSum(j, 1, j, k-1) - GetSum(i+1, k, j-1, k) + (k << 1) + j - i - 3
					fmt.Printf("f[%d] = %d\n", k, f[k])
				}
				for k := m - 1; k != 3; k-- {
					if f[k+1] < f[k] {
						f[k] = f[k+1]
					}
				}
				for k := 1; k != m-2; k++ {
					cur := f[k+3] - GetSum(i+1, 1, j-1, k) + GetSum(i, 1, i, k) + GetSum(j, 1, j, k) - GetSum(i+1, k, j-1, k) - (k << 1) + j - i - 1
					fmt.Printf("%d %d %d %d\n", GetSum(i+1, 1, j-1, k), GetSum(i, 1, i, k), GetSum(j, 1, j, k), GetSum(i+1, k, j-1, k))
					fmt.Printf("%d %d %d\n", k, f[k+3], cur)

					if cur < ans {
						ans = cur
					}
				}
			}
		}
		out.WriteString(strconv.Itoa(ans) + "\n")
		//fmt.Println(n, m)
		//for i := 1; i <= n; i++ {
		//	for j := 1; j <= m; j++ {
		//		fmt.Printf("%d ", sum[i][j])
		//	}
		//	fmt.Println()
		//}
	}
}

/*
2
5 4
1000
0000
0110
0000
0001

9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000

*/

/*
1
9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000

*/

package main

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

const maxn = 409

var sum [maxn][maxn]int
var f [maxn]int

func GetSum(lx, ly, rx, ry int) int {
	return sum[rx][ry] - sum[rx][ly-1] - sum[lx-1][ry] + sum[lx-1][ly-1]
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	read_int := func() (x int) {
		c, _ := in.ReadByte()
		for ; c < '0'; c, _ = in.ReadByte() {
		}
		for ; c >= '0'; c, _ = in.ReadByte() {
			x = x*10 + int(c-'0')
		}
		return
	}
	t = read_int()
	for ; t > 0; t-- {
		for i := 0; i < maxn; i++ {
			f[i] = 0
			for j := 0; j < maxn; j++ {
				sum[i][j] = 0
			}
		}
		var n, m int
		ans := 99
		n = read_int()
		m = read_int()
		for i := 1; i <= n; i++ {
			s, _ := in.ReadString('\n')
			for k, c := range s {
				if '1' == c {
					sum[i][k+1] = 1
				} else {
					sum[i][k+1] = 0
				}
			}
		}
		for i := 1; i <= n; i++ {
			for j := 1; j <= m; j++ {
				sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1]
				//fmt.Printf("%d ", sum[i][j])
			}
			//fmt.Println()
		}
		for i := 1; i <= n; i++ {
			for j := i + 4; j <= n; j++ {
				for k := 4; k <= m; k++ {
					f[k] = GetSum(i+1, 1, j-1, k-1) - GetSum(i, 1, i, k-1) - GetSum(j, 1, j, k-1) - GetSum(i+1, k, j-1, k) + (k << 1) + j - i - 3
					//fmt.Printf("f[%d] = %d\n", k, f[k])
				}
				for k := m - 1; k != 3; k-- {
					if f[k+1] < f[k] {
						f[k] = f[k+1]
					}
				}
				for k := 1; k != m-2; k++ {
					cur := f[k+3] - GetSum(i+1, 1, j-1, k) + GetSum(i, 1, i, k) + GetSum(j, 1, j, k) - GetSum(i+1, k, j-1, k) - (k << 1) + j - i - 1
					//fmt.Printf("%d %d %d %d\n", GetSum(i+1, 1, j-1, k), GetSum(i, 1, i, k), GetSum(j, 1, j, k), GetSum(i+1, k, j-1, k))
					//fmt.Printf("%d %d %d\n", k, f[k+3], cur)

					if cur < ans {
						ans = cur
					}
				}
			}
		}
		out.WriteString(strconv.Itoa(ans) + "\n")
		//fmt.Println(n, m)
		//for i := 1; i <= n; i++ {
		//	for j := 1; j <= m; j++ {
		//		fmt.Printf("%d ", sum[i][j])
		//	}
		//	fmt.Println()
		//}
	}
}

/*
2
5 4
1000
0000
0110
0000
0001

9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000

*/

/*
1
9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000

*/

package main

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

const maxn = 409

var sum [maxn][maxn]int
var f [maxn]int

func GetSum(lx, ly, rx, ry int) int {
	return sum[rx][ry] - sum[rx][ly-1] - sum[lx-1][ry] + sum[lx-1][ly-1]
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	read_int := func() (x int) {
		c, _ := in.ReadByte()
		for ; c < '0'; c, _ = in.ReadByte() {
		}
		for ; c >= '0'; c, _ = in.ReadByte() {
			x = x*10 + int(c-'0')
		}
		return
	}
	t = read_int()
	for ; t > 0; t-- {
		var n, m int
		ans := 999999
		n = read_int()
		m = read_int()
		for i := 1; i <= n; i++ {
			s, _ := in.ReadString('\n')
			for k, c := range s {
				if '1' == c {
					sum[i][k+1] = 1
				} else {
					sum[i][k+1] = 0
				}
			}
		}
		for i := 1; i <= n; i++ {
			for j := 1; j <= m; j++ {
				sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1]
				//fmt.Printf("%d ", sum[i][j])
			}
			//fmt.Println()
		}
		for i := 1; i <= n; i++ {
			for j := i + 4; j <= n; j++ {
				for k := 4; k <= m; k++ {
					f[k] = GetSum(i+1, 1, j-1, k-1) - GetSum(i, 1, i, k-1) - GetSum(j, 1, j, k-1) - GetSum(i+1, k, j-1, k) + (k << 1) + j - i - 3
					//fmt.Printf("f[%d] = %d\n", k, f[k])
				}
				for k := m - 1; k != 3; k-- {
					if f[k+1] < f[k] {
						f[k] = f[k+1]
					}
				}
				for k := 1; k != m-2; k++ {
					cur := f[k+3] - GetSum(i+1, 1, j-1, k) + GetSum(i, 1, i, k) + GetSum(j, 1, j, k) - GetSum(i+1, k, j-1, k) - (k << 1) + j - i - 1
					//fmt.Printf("%d %d %d %d\n", GetSum(i+1, 1, j-1, k), GetSum(i, 1, i, k), GetSum(j, 1, j, k), GetSum(i+1, k, j-1, k))
					//fmt.Printf("%d %d %d\n", k, f[k+3], cur)

					if cur < ans {
						ans = cur
					}
				}
			}
		}
		out.WriteString(strconv.Itoa(ans) + "\n")
		//fmt.Println(n, m)
		//for i := 1; i <= n; i++ {
		//	for j := 1; j <= m; j++ {
		//		fmt.Printf("%d ", sum[i][j])
		//	}
		//	fmt.Println()
		//}
	}
}

/*
2
5 4
1000
0000
0110
0000
0001

9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000

*/

/*
1
9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000

*/

package main

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

const maxn = 409

var sum [maxn][maxn]int
var f [maxn]int

func GetSum(lx, ly, rx, ry int) int {
	return sum[rx][ry] - sum[rx][ly-1] - sum[lx-1][ry] + sum[lx-1][ly-1]
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	read_int := func() (x int) {
		c, _ := in.ReadByte()
		for ; c < '0'; c, _ = in.ReadByte() {
		}
		for ; c >= '0'; c, _ = in.ReadByte() {
			x = x*10 + int(c-'0')
		}
		return
	}
	t = read_int()
	for ; t > 0; t-- {
		var n, m int
		ans := 99
		n = read_int()
		m = read_int()
		for i := 1; i <= n; i++ {
			s, _ := in.ReadString('\n')
			for k, c := range s {
				if '1' == c {
					sum[i][k+1] = 1
				} else {
					sum[i][k+1] = 0
				}
			}
		}
		for i := 1; i <= n; i++ {
			for j := 1; j <= m; j++ {
				sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1]
				//fmt.Printf("%d ", sum[i][j])
			}
			//fmt.Println()
		}
		for i := 1; i <= n; i++ {
			for j := i + 4; j <= n; j++ {
				for k := 4; k <= m; k++ {
					f[k] = GetSum(i+1, 1, j-1, k-1) - GetSum(i, 1, i, k-1) - GetSum(j, 1, j, k-1) - GetSum(i+1, k, j-1, k) + (k << 1) + j - i - 3
					//fmt.Printf("f[%d] = %d\n", k, f[k])
				}
				for k := m - 1; k != 3; k-- {
					if f[k+1] < f[k] {
						f[k] = f[k+1]
					}
				}
				for k := 1; k != m-2; k++ {
					cur := f[k+3] - GetSum(i+1, 1, j-1, k) + GetSum(i, 1, i, k) + GetSum(j, 1, j, k) - GetSum(i+1, k, j-1, k) - (k << 1) + j - i - 1
					//fmt.Printf("%d %d %d %d\n", GetSum(i+1, 1, j-1, k), GetSum(i, 1, i, k), GetSum(j, 1, j, k), GetSum(i+1, k, j-1, k))
					//fmt.Printf("%d %d %d\n", k, f[k+3], cur)

					if cur < ans {
						ans = cur
					}
				}
			}
		}
		out.WriteString(strconv.Itoa(ans) + "\n")
		//fmt.Println(n, m)
		//for i := 1; i <= n; i++ {
		//	for j := 1; j <= m; j++ {
		//		fmt.Printf("%d ", sum[i][j])
		//	}
		//	fmt.Println()
		//}
	}
}

/*
2
5 4
1000
0000
0110
0000
0001

9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000

*/

/*
1
9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000

*/


Two players decided to play one interesting card game.There is a deck of $$$n$$$ cards, with values from $$$1$$$ to $$$n$$$. The values of cards are pairwise different (this means that no two different cards have equal values). At the beginning of the game, the deck is completely distributed between players such that each player has at least one card. The game goes as follows: on each turn, each player chooses one of their cards (whichever they want) and puts on the table, so that the other player doesn't see which card they chose. After that, both cards are revealed, and the player, value of whose card was larger, takes both cards in his hand. Note that as all cards have different values, one of the cards will be strictly larger than the other one. Every card may be played any amount of times. The player loses if he doesn't have any cards.For example, suppose that $$$n = 5$$$, the first player has cards with values $$$2$$$ and $$$3$$$, and the second player has cards with values $$$1$$$, $$$4$$$, $$$5$$$. Then one possible flow of the game is:The first player chooses the card $$$3$$$. The second player chooses the card $$$1$$$. As $$$3>1$$$, the first player gets both cards. Now the first player has cards $$$1$$$, $$$2$$$, $$$3$$$, the second player has cards $$$4$$$, $$$5$$$.The first player chooses the card $$$3$$$. The second player chooses the card $$$4$$$. As $$$3<4$$$, the second player gets both cards. Now the first player has cards $$$1$$$, $$$2$$$. The second player has cards $$$3$$$, $$$4$$$, $$$5$$$.The first player chooses the card $$$1$$$. The second player chooses the card $$$3$$$. As $$$1<3$$$, the second player gets both cards. Now the first player has only the card $$$2$$$. The second player has cards $$$1$$$, $$$3$$$, $$$4$$$, $$$5$$$.The first player chooses the card $$$2$$$. The second player chooses the card $$$4$$$. As $$$2<4$$$, the second player gets both cards. Now the first player is out of cards and loses. Therefore, the second player wins.Who will win if both players are playing optimally? It can be shown that one of the players has a winning strategy.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The description of the test cases follows. The first line of each test case contains three integers $$$n$$$, $$$k_1$$$, $$$k_2$$$ ($$$2 \le n \le 100, 1 \le k_1 \le n - 1, 1 \le k_2 \le n - 1, k_1 + k_2 = n$$$) — the number of cards, number of cards owned by the first player and second player correspondingly. The second line of each test case contains $$$k_1$$$ integers $$$a_1, \dots, a_{k_1}$$$ ($$$1 \le a_i \le n$$$) — the values of cards of the first player. The third line of each test case contains $$$k_2$$$ integers $$$b_1, \dots, b_{k_2}$$$ ($$$1 \le b_i \le n$$$) — the values of cards of the second player. It is guaranteed that the values of all cards are different.

NoteIn the first test case of the example, there is only one possible move for every player: the first player will put $$$2$$$, the second player will put $$$1$$$. $$$2>1$$$, so the first player will get both cards and will win.In the second test case of the example, it can be shown that it is the second player who has a winning strategy. One possible flow of the game is illustrated in the statement.

// A. Card Game
/*
Two players decided to play one interesting card game.

There is a deck of 𝑛 cards, with values from 1 to 𝑛. The values of cards are pairwise different (this means that no two different cards have equal values). At the beginning of the game, the deck is completely distributed between players such that each player has at least one card.

The game goes as follows: on each turn, each player chooses one of their cards (whichever they want) and puts on the table, so that the other player doesn't see which card they chose. After that, both cards are revealed, and the player, value of whose card was larger, takes both cards in his hand. Note that as all cards have different values, one of the cards will be strictly larger than the other one. Every card may be played any amount of times. The player loses if he doesn't have any cards.

For example, suppose that 𝑛=5, the first player has cards with values 2 and 3, and the second player has cards with values 1, 4, 5. Then one possible flow of the game is:

    The first player chooses the card 3. The second player chooses the card 1. As 3>1, the first player gets both cards. Now the first player has cards 1, 2, 3, the second player has cards 4, 5.

	 	The first player chooses the card 3. The second player chooses the card 4. As 3<4, the second player gets both cards. Now the first player has cards 1, 2. The second player has cards 3, 4, 5.

	 	The first player chooses the card 1. The second player chooses the card 3. As 1<3, the second player gets both cards. Now the first player has only the card 2. The second player has cards 1, 3, 4, 5.

	 	The first player chooses the card 2. The second player chooses the card 4. As 2<4, the second player gets both cards. Now the first player is out of cards and loses. Therefore, the second player wins.

Who will win if both players are playing optimally? It can be shown that one of the players has a winning strategy.

Input
Each test contains multiple test cases. The first line contains the number of test cases 𝑡(1≤𝑡≤100). The description of the test cases follows.

The first line of each test case contains three integers 𝑛, 𝑘1, 𝑘2 (2≤𝑛≤100,1≤𝑘1≤𝑛−1,1≤𝑘2≤𝑛−1,𝑘1+𝑘2=𝑛) — the number of cards, number of cards owned by the first player and second player correspondingly.

The second line of each test case contains 𝑘1 integers 𝑎1,…,𝑎𝑘1 (1≤𝑎𝑖≤𝑛) — the values of cards of the first player.

The third line of each test case contains 𝑘2 integers 𝑏1,…,𝑏𝑘2 (1≤𝑏𝑖≤𝑛) — the values of cards of the second player.

It is guaranteed that the values of all cards are different.

Output
For each test case, output "YES" in a separate line, if the first player wins. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower).

Example
Input
2
2 1 1
2
1
5 2 3
2 3
1 4 5

Output
YES
NO

Note
In the first test case of the example, there is only one possible move for every player: the first player will put 2, the second player will put 1. 2>1, so the first player will get both cards and will win.

In the second test case of the example, it can be shown that it is the second player who has a winning strategy. One possible flow of the game is illustrated in the statement.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	t, _ := strconv.Atoi(strings.TrimSpace(input1))

	for ; t > 0; t-- {
		input2, _ := reader.ReadString('\n')
		arr1 := strings.Split(strings.TrimSpace(input2), " ")
		k1, _ := strconv.Atoi(arr1[1])
		k2, _ := strconv.Atoi(arr1[2])

		input3, _ := reader.ReadString('\n')
		arr2 := strings.Split(strings.TrimSpace(input3), " ")

		input4, _ := reader.ReadString('\n')
		arr3 := strings.Split(strings.TrimSpace(input4), " ")

		max1, max2 := 0, 0
		for i := 0; i < k1; i++ {
			v, _ := strconv.Atoi(arr2[i])
			if v > max1 {
				max1 = v
			}
		}
		for i := 0; i < k2; i++ {
			v, _ := strconv.Atoi(arr3[i])
			if v > max2 {
				max2 = v
			}
		}

		if max1 > max2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func solve() {
	var n, k1, k2, a, b, winner int
	fmt.Scan(&n, &k1, &k2)
	for ; k1 > 0; k1-- {
		fmt.Scan(&a)
		if a == n {
			winner = 1
		}
	}
	for ; k2 > 0; k2-- {
		fmt.Scan(&b)
	}
	if winner == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		solve()
	}
}

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, k1, k2 := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &n, &k1, &k2)
		a := 0
		for i := 0; i < k1; i++ {
			tmp := 0
			fmt.Fscanf(in, "%d", &tmp)
			if tmp > a {
				a = tmp
			}
		}
		fmt.Fscanf(in, "\n")
		b := 0
		for i := 0; i < k2; i++ {
			tmp := 0
			fmt.Fscanf(in, "%d", &tmp)
			if tmp > b {
				b = tmp
			}
		}
		fmt.Fscanf(in, "\n")
		if a > b {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

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

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

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

	t, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	for i := int64(0); i < t; i++ {
		readLine(reader)
		checkError(err)
		max1, max2 := int64(0), int64(0)
		line := strings.Split(readLine(reader), " ")
		for _, s := range line {
			v, err := strconv.ParseInt(s, 10, 64)
			checkError(err)
			if v > max1 {
				max1 = v
			}
		}
		line = strings.Split(readLine(reader), " ")
		for _, s := range line {
			v, err := strconv.ParseInt(s, 10, 64)
			checkError(err)
			if v > max2 {
				max2 = v
			}
		}

		if max1 > max2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func readLine(reader *bufio.Reader) string {
	str, err := reader.ReadString('\n')
	if err == io.EOF {
		return ""
	}

	return strings.TrimSpace(str)
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var t, n, k1, k2, c, max1, max2 int
	fmt.Fscanln(reader, &t)
	for i := 0; i < t; i++ {
		fmt.Fscanln(reader, &n, &k1, &k2)
		max1 = 0
		for j := 0; j < k1; j++ {
			if j == k1-1 {
				fmt.Fscanf(reader, "%d\n", &c)
			} else {
				fmt.Fscanf(reader, "%d", &c)
			}
			if c > max1 {
				max1 = c
			}
		}
		max2 = 0
		for j := 0; j < k2; j++ {
			if j == k2-1 && i < t - 1 {
				fmt.Fscanf(reader, "%d\n", &c)
			} else {
				fmt.Fscanf(reader, "%d", &c)
			}
			if c > max2 {
				max2 = c
			}
		}
		if max1 > max2 {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		n, k1, k2 := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &n, &k1, &k2)

		p1max := -1
		p2max := -1

		for j := 0; j < k1; j++ {
			cardNumber := 0
			fmt.Fscanf(in, "%d", &cardNumber)
			if cardNumber > p1max {
				p1max = cardNumber
			}
		}
		fmt.Fscanf(in, "\n")

		for j := 0; j < k2; j++ {
			cardNumber := 0
			fmt.Fscanf(in, "%d", &cardNumber)
			if cardNumber > p2max {
				p2max = cardNumber
			}
		}
		fmt.Fscanf(in, "\n")

		if p1max > p2max {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

func main() {

	var T, n, k1, k2, i, j, k, temp  uint
	scanf("%d \n", &T)

	results := []string{}

	for i=0; i<T; i++ {
		scanf("%d %d %d \n", &n, &k1, &k2)
		p1Cards := []uint{}
		p2Cards := []uint{}

		for j=0; j<k1; j++ {
			if j == k1 - 1 {
				scanf("%d \n", &temp)
			}else {
				scanf("%d ", &temp)
			}
			p1Cards = append(p1Cards, temp)
		}

		for k=0; k<k2; k++ {
			if k == k2 - 1 {
				scanf("%d \n", &temp)
			}else {
				scanf("%d ", &temp)
			}
			p2Cards = append(p2Cards, temp)
		}

		if getMax(p2Cards) > getMax(p1Cards) {
			results = append(results, "NO")
		}else {
			results = append(results, "YES")
		}

	}

	for _, v := range results {
		fmt.Println(v)
	}
}

func getMax(a []uint) uint{
	var max uint
	for _, v := range a {
		if v > max {
			max = v
		}
	}

	return max
}

package main

import (
	"fmt"
)

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

	for i := 0; i < t; i++ {
		var n, k1, k2 int
		_, _ = fmt.Scan(&n, &k1, &k2)
		var mx1, mx2, cur int
		for c := 0; c < k1; c++ {
			_, _ = fmt.Scan(&cur)
			if mx1 < cur {
				mx1 = cur
			}
		}
		for c := 0; c < k2; c++ {
			_, _ = fmt.Scan(&cur)
			if mx2 < cur {
				mx2 = cur
			}
		}

		if mx1 > mx2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	sc := NewScanner()
	t := sc.NextInt()
	for i := 0; i < t; i++ {
		_, _, _ = sc.NextInt(), sc.NextInt(), sc.NextInt()
		a := sc.NextIntArray()
		q1 := maxA(a...)
		b := sc.NextIntArray()
		q2 := maxA(b...)
		if q1 > q2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}
func maxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = max(s, v)
	}
	return s
}

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

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

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

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

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

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

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

	return mp
}

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

package main

import (
	"fmt"
	"sort"
)

func main() {
	var t, n int
	var k1, k2 int
	var a[100] int
	var b[100] int

	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n, &k1, &k2)
		for j:=0; j<k1; j++ {
			fmt.Scan(&a[j])
		}
		for m:=0; m<k2; m++ {
			fmt.Scan(&b[m])
		}
		sa := a[0 : k1]
		sb := b[0 : k2]
		sort.Slice(sa, func(i, j int) bool { return sa[i] > sa[j] })
		sort.Slice(sb, func(i, j int) bool { return sb[i] > sb[j] })
		if sa[0] > sb[0] {
			fmt.Print("\nYES")
		} else {
			fmt.Print("\nNO")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int

	fmt.Scan(&t)

	for t > 0 {
	    var n, k1, k2, l1, l2 int

		fmt.Scan(&n, &k1, &k2)

		for i := 0; i < k1; i++ {
		    var t1 int
			fmt.Scan(&t1)
			l1 = Max(t1, l1)
		}
		for i := 0; i < k2; i++ {
		    var t2 int
			fmt.Scan(&t2)
			l2 = Max(t2, l2)
		}

		if l1 > l2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

		t--
	}
}

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

package main

import "fmt"

func main(){
    var n int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        var t, p1, p2, m1, m2 int
        fmt.Scan(&t, &p1, &p2)
        for x := 0; x < p1; x++ {
            fmt.Scan(&t)
            if (t > m1) {
                m1 = t
            }
        }
        for x := 0; x < p2; x++ {
            fmt.Scan(&t)
            if (t > m2) {
                m2 = t
            }
        }
        if (m1 > m2) {
            fmt.Println("YES")
        } else {
            fmt.Println("NO")
        }
    }
}

package main

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

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

	var t, n, k1, k2 int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 1; i <= t; i++ {
		fmt.Fscanf(reader, "%d %d %d\n", &n, &k1, &k2)
		var temp int
		found := false
		for j := 1; j <= k1; j++ {
			fmt.Fscanf(reader, "%d", &temp)
			if temp == n {
				found = true
			}
		}
		fmt.Fscanf(reader, "\n")
		for j := 1; j <= k2; j++ {
			fmt.Fscanf(reader, "%d", &temp)
		}
		fmt.Fscanf(reader, "\n")
		if found {
			fmt.Fprintf(writer, "YES\n")
		} else {
			fmt.Fprintf(writer, "NO\n")
		}
	}
}

package main

import (
  "fmt"
  "sort"
)

type heap struct {
  array []int
}

func (h *heap) push(val int) {
  h.array = append(h.array, val)
  cur := len(h.array) - 1
  for cur > 0 {
    var parent int
    if (cur & 1) == 1 {
      parent = (cur - 1) / 2
    } else {
      parent = (cur - 2) / 2
    }
    if h.array[cur] < h.array[parent] {
      h.array[cur], h.array[parent] = h.array[parent], h.array[cur]
      cur = parent
    } else {
      break
    }
  }
}

func (h *heap) pop() int {
  res := h.array[0]
  h.array[0], h.array[len(h.array)-1] = h.array[len(h.array)-1], h.array[0]
  h.array = h.array[:len(h.array)-1]
  cur := 0
  for cur < len(h.array) {
    smallest := cur
    if cur*2+1 < len(h.array) && h.array[smallest] > h.array[cur*2+1] {
      smallest = cur*2 + 1
    }
    if cur*2+2 < len(h.array) && h.array[smallest] > h.array[cur*2+2] {
      smallest = cur*2 + 2
    }
    if smallest != cur {
      h.array[smallest], h.array[cur] = h.array[cur], h.array[smallest]
      cur = smallest
    } else {
      break
    }
  }
  return res
}

func main() {
  var T int
  fmt.Scan(&T)
  for T > 0 {
    T--
    var n, k1, k2 int
    fmt.Scan(&n, &k1, &k2)
    p1, p2 := make([]int, k1), make([]int, k2)
    for i, _ := range p1 {
      fmt.Scan(&p1[i])
    }
    for i, _ := range p2 {
      fmt.Scan(&p2[i])
    }
    sort.Ints(p1)
    sort.Ints(p2)
    if p1[k1-1]>p2[k2-1]{
      fmt.Println("YES")
    }else{
      fmt.Println("NO")
    }
  }

}

package main

import "fmt"

func solve() {
	var n, k1, k2, a, b, maxA int
	fmt.Scan(&n, &k1, &k2)
	for ; k1 > 0; k1-- {
		fmt.Scan(&a)
		if maxA < a {
			maxA = a
		}
	}
	for ; k2 > 0; k2-- {
		fmt.Scan(&b)
		if maxA < b {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		solve()
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, k1, k2, t1, t2 int

	fmt.Scan(&t)

	for t > 0 {
		fmt.Println(t)
		fmt.Scan(&n, &k1, &k2)
		var a = make([]int, k1)
		var b = make([]int, k2)

		for i := 0; i < k1; i++ {
			if _, err := fmt.Scan(&a[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t1 = a[0]
			}
			if i > 0 && a[i-1] < a[i] {
				t1 = a[i]
			}
		}
		for i := 0; i < k2; i++ {
			if _, err := fmt.Scan(&b[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t2 = b[0]
			}
			if i > 0 && b[i-1] < b[i] {
				t2 = b[i]
			}
		}

		if t1 > t2 {
			fmt.Print("YES")
		} else {
			fmt.Print("NO")
		}

		t--
		if t > 0 {
			fmt.Println()
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, k1, k2, t1, t2 int

	fmt.Scan(&t)

	for t > 0 {
		fmt.Scan(&n, &k1, &k2)

		var k1A = make([]int, k1)
		var k2A = make([]int, k2)

		for i := 0; i < k1; i++ {
			if _, err := fmt.Scan(&k1A[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t1 = k1A[0]
			}
			if i > 0 && k1A[i-1] < k1A[i] {
				t1 = k1A[i]
			}
		}
		for i := 0; i < k2; i++ {
			if _, err := fmt.Scan(&k2A[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t2 = k2A[0]
			}
			if i > 0 && k2A[i-1] < k2A[i] {
				t2 = k2A[i]
			}
		}

		if t1 > t2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

		t--
	}

}

package main

import (
	"fmt"
)

func main() {
	var t, n, k1, k2, t1, t2 int

	if _, err := fmt.Scan(&t); err != nil {
		panic(err)
	}

	for t > 0 {
		if _, err := fmt.Scan(&n, &k1, &k2); err != nil {
			panic(err)
		}

		var a = make([]int, k1)
		var b = make([]int, k2)

		for i := 0; i < k1; i++ {
			if _, err := fmt.Scan(&a[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t1 = a[0]
			}
			if i > 0 && a[i-1] < a[i] {
				t1 = a[i]
			}
		}
		for i := 0; i < k2; i++ {
			if _, err := fmt.Scan(&b[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t2 = b[0]
			}
			if i > 0 && b[i-1] < b[i] {
				t2 = b[i]
			}
		}

		if t1 > t2 {
			fmt.Print("YES")
		} else {
			fmt.Print("NO")
		}

		t--
		if t > 0 {
			fmt.Println()
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, k1, k2, t1, t2 int

	fmt.Scan(&t)

	for t > 0 {
		fmt.Scan(&n, &k1, &k2)
		var a = make([]int, k1)
		var b = make([]int, k2)

		for i := 0; i < k1; i++ {
			if _, err := fmt.Scan(&a[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t1 = a[0]
			}
			if i > 0 && a[i-1] < a[i] {
				t1 = a[i]
			}
		}
		for i := 0; i < k2; i++ {
			if _, err := fmt.Scan(&b[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t2 = b[0]
			}
			if i > 0 && b[i-1] < b[i] {
				t2 = b[i]
			}
		}

		if t1 > t2 {
			fmt.Print("YES")
		} else {
			fmt.Print("NO")
		}

		t--
		if t > 0 {
			fmt.Println()
		}
	}
}


One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of dollars and then sell it no more than once in n days. According to Martian laws, one can buy only an integer number of dollars. Which maximal sum of money in bourles can Vasya get by the end of day n?

The first line contains two integers n and b (1 ≤ n, b ≤ 2000) — the number of days and the initial number of money in bourles. The next line contains n integers ai (1 ≤ ai ≤ 2000) — the prices of Martian dollars.

Print the single number — which maximal sum of money in bourles can Vasya get by the end of day n.

package main

import "fmt"

var n,b int
var dollars [2001]int

func main(){
    fmt.Scanf("%d %d\n", &n, &b)
    for i:=0; i<n; i++{
        fmt.Scanf("%d", &dollars[i])
    }
    max_profit := b
    for i:=0; i<n; i++{
        for j:=i+1; j<n; j++{
            profit:=get_profit(i,j, b)
            if profit > max_profit{
                max_profit = profit
            }
        }
    }
    fmt.Println(max_profit)
}

func get_profit(i int, j int, b int) int {
    amount := b % dollars[i]
    to_buy := (b-amount) / dollars[i]
    b -= to_buy * dollars[i]
    b += to_buy * dollars[j]
    return b
}


You are given an array consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, and a positive integer $$$m$$$. It is guaranteed that $$$m$$$ is a divisor of $$$n$$$.In a single move, you can choose any position $$$i$$$ between $$$1$$$ and $$$n$$$ and increase $$$a_i$$$ by $$$1$$$.Let's calculate $$$c_r$$$ ($$$0 \le r \le m-1)$$$ — the number of elements having remainder $$$r$$$ when divided by $$$m$$$. In other words, for each remainder, let's find the number of corresponding elements in $$$a$$$ with that remainder.Your task is to change the array in such a way that $$$c_0 = c_1 = \dots = c_{m-1} = \frac{n}{m}$$$.Find the minimum number of moves to satisfy the above requirement.

The first line of input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5, 1 \le m \le n$$$). It is guaranteed that $$$m$$$ is a divisor of $$$n$$$. The second line of input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$), the elements of the array.

In the first line, print a single integer — the minimum number of moves required to satisfy the following condition: for each remainder from $$$0$$$ to $$$m - 1$$$, the number of elements of the array having this remainder equals $$$\frac{n}{m}$$$. In the second line, print any array satisfying the condition and can be obtained from the given array with the minimum number of moves. The values of the elements of the resulting array must not exceed $$$10^{18}$$$.

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"bytes"
)

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var m, n int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	a := make([]int, n)
	mod := make([]int, m)
	plus := make([][]int, m)
	for i := 0;i < n;i ++ {
		fmt.Fscanf(reader, "%d ", &a[i])
		mod[a[i] % m] ++
	}
	for i := 0;i < m;i ++ {
		plus[i] = make([]int, 0, mod[i])
	}
	stack := make([]int, 0, n)
	var ans uint64
	for i := 0;i < 2 * m - 1;i ++ {
		if mod[i % m] > n / m {
			stack = append(stack, i % m)
		} else if mod[i % m] < n / m {
			for mod[i % m] != n / m && len(stack) != 0 {
				pos := stack[len(stack) - 1]
				d1, d2 := n / m - mod[i % m], mod[pos] - n / m
				if d2 >= d1 {
					ans += uint64(d1) * uint64((i + 2 * m - pos) % m)
					for j := 0;j < d1;j ++ {
						plus[pos] = append(plus[pos], (i + 2 * m - pos) % m)
					}
					mod[pos], mod[i % m] = mod[pos] - d1, mod[i % m] + d1
				} else {
					ans += uint64(d2) * uint64((i + 2 * m - pos) % m)
					for j := 0;j < d2;j ++ {
						plus[pos] = append(plus[pos], (i + 2 * m - pos) % m)
					}
					mod[pos], mod[i % m] = mod[pos] - d2, mod[i % m] + d2
					stack = stack[:len(stack) - 1]
				}
			}
		}
	}
	fmt.Printf("%d\n", ans)
	for i := 0;i < n;i ++ {
		if len(plus[a[i] % m]) > 0 {
			plus[a[i] % m], a[i] = plus[a[i] % m][1:], a[i] + plus[a[i] % m][0]
		}
		fmt.Printf("%d ", a[i])
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF999D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ i, v int }

	var n, m int
	Fscan(in, &n, &m)
	sz := n / m
	a := make([]int, n)
	id := make([][]int, m)
	for i := range a {
		Fscan(in, &a[i])
		id[a[i]%m] = append(id[a[i]%m], i)
	}

	ans := int64(0)
	var todo []pair
	for v := 0; v < 2*m; v++ {
		i := v % m
		for len(id[i]) > sz {
			j := id[i][0]
			id[i] = id[i][1:]
			todo = append(todo, pair{j, v})
		}
		for len(todo) > 0 && len(id[i]) < sz {
			p := todo[0]
			todo = todo[1:]
			id[i] = append(id[i], p.i)
			d := v - p.v
			a[p.i] += d
			ans += int64(d)
		}
	}
	Fprintln(out, ans)
	for _, v := range a {
		Fprint(out, v, " ")
	}
}

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

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, index int64
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var indexes [][]int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	indexes = make([][]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		r := a[i] % m
		remainders[r]++
		indexes[r] = append(indexes[r], i)
	}

	ans := int64(0)
	q := make([]rem, 0)
	for i := int64(0); i < 2*m; i++ {
		r := i % m
		for l := len(indexes[r]); remainders[r] > k; l-- {
			q = append(q, rem{r: r, index: indexes[r][l-1]})
			indexes[r] = indexes[r][:l-1]
			remainders[r]--
		}
		for l := len(q); remainders[r] < k && l > 0; l-- {
			remainders[r]++
			t := q[l-1]
			q = q[:l-1]
			step := (m + i - t.r) % m
			ans += step
			a[t.index] += step
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"bytes"
)

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var m, n int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	a := make([]int, n)
	mod := make([]int, m)
	plus := make([][]int, m)
	for i := 0;i < n;i ++ {
		fmt.Fscanf(reader, "%d ", &a[i])
		mod[a[i] % m] ++
	}
	for i := 0;i < m;i ++ {
		plus[i] = []int{}
	}
	stack := make([]int, 0, n)
	ans := 0
	for i := 0;i < 2 * m - 1;i ++ {
		if mod[i % m] > n / m {
			stack = append(stack, i % m)
		} else if mod[i % m] < n / m {
			for mod[i % m] != n / m && len(stack) != 0 {
				pos := stack[len(stack) - 1]
				d1, d2 := n / m - mod[i % m], mod[pos] - n / m
				if d2 >= d1 {
					ans += d1 * ((i + 2 * m - pos) % m)
					for j := 0;j < d1;j ++ {
						plus[pos] = append(plus[pos], (i + 2 * m - pos) % m)
					}
					mod[pos], mod[i % m] = mod[pos] - d1, mod[i % m] + d1
				} else {
					ans += d2 * ((i + 2 * m - pos) % m)
					for j := 0;j < d2;j ++ {
						plus[pos] = append(plus[pos], (i + 2 * m - pos) % m)
					}
					mod[pos], mod[i % m] = mod[pos] - d2, mod[i % m] + d2
				}
			}
		}
	}
	fmt.Printf("%d\n", ans)
	for i := 0;i < n;i ++ {
		if len(plus[a[i] % m]) > 0 {
			plus[a[i] % m], a[i] = plus[a[i] % m][1:], a[i] + plus[a[i] % m][0]
		}
		fmt.Printf("%d ", a[i])
	}
}

package main

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

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

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

	var n, m ,d int
	Fscan(in, &n, &m)
	d=n/m

	arr:=make([]int, n)

	for i := 0; i < n; i++ {
		Fscan(in, &arr[i])
		arr[i]%=m
	}

	sort.Ints(arr)

	ans := int64(0)
	for i := 0; i < n; i++ {
		ans+=int64(abs(arr[i] - i/d))
	}

	Fprintln(out, ans)
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, count int
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var lesser []int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		remainders[a[i] % m]++
	}
	lesser = make([]int64, 0)
	for i := int64(0); i < m; i++ {
		if remainders[i] < k {
			lesser = append(lesser, i)
		}
	}
	ans := int64(0)
	p1 := 0
	for i := int64(0); i < n; i++ {
		r := a[i] % m
		if remainders[r] > k {
			remainders[r]--
			steps := lesser[p1] - r
			if r > lesser[p1] {
				steps = m - r + lesser[p1]
			}
			ans += steps
			a[i] += steps
			remainders[lesser[p1]]++
			if remainders[lesser[p1]] == k {
				p1++
			}
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, count int
}

var n, m, k int
var a [MaxN]int
var remainders []int
var lesser []int

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int, m)
	for i := 0; i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		remainders[a[i] % m]++
	}
	lesser = make([]int, 0)
	for i := 0; i < m; i++ {
		if remainders[i] < k {
			lesser = append(lesser, i)
		}
	}
	ans := 0
	p1 := 0
	for i := 0; i < n; i++ {
		r := a[i] % m
		if remainders[r] > k {
			remainders[r]--
			steps := lesser[p1] - r
			if r > lesser[p1] {
				steps = n - r + lesser[p1]
			}
			ans += steps
			a[i] += steps
			remainders[lesser[p1]]++
			if remainders[lesser[p1]] == k {
				p1++
			}
		}
	}
	fmt.Println(ans)
	for i := 0; i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, count int
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var lesser []int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		remainders[a[i] % m]++
	}
	lesser = make([]int64, 0)
	for i := int64(0); i < m; i++ {
		if remainders[i] < k {
			lesser = append(lesser, i)
		}
	}
	ans := int64(0)
	p1 := 0
	for i := int64(0); i < n; i++ {
		r := a[i] % m
		if remainders[r] > k {
			remainders[r]--
			steps := lesser[p1] - r
			if r > lesser[p1] {
				steps = n - r + lesser[p1]
			}
			ans += steps
			a[i] += steps
			remainders[lesser[p1]]++
			if remainders[lesser[p1]] == k {
				p1++
			}
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, count int
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var lesser []int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		remainders[a[i] % m]++
	}
	lesser = make([]int64, 0)
	for i := int64(m - 1); i >= 0; i-- {
		if remainders[i] < k {
			lesser = append(lesser, i)
		}
	}
	ans := int64(0)
	p1, p2 := 0, len(lesser) - 1
	for i := int64(0); i < n; i++ {
		r := a[i] % m
		if remainders[r] > k {
			remainders[r]--
			steps1 := lesser[p1] - r
			if r > lesser[p1] {
				steps1 = m - r + lesser[p1]
			}
			steps2 := lesser[p2] - r
			if r > lesser[p2] {
				steps1 = m - r + lesser[p2]
			}
			if steps1 > steps2 {
				ans += steps1
				a[i] += steps1
				remainders[lesser[p1]]++
				if remainders[lesser[p1]] == k {
					p1++
				}
			} else {
				ans += steps2
				a[i] += steps2
				remainders[lesser[p2]]++
				if remainders[lesser[p2]] == k {
					p2--
				}
			}
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, count int
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var lesser []int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		remainders[a[i] % m]++
	}
	lesser = make([]int64, 0)
	for i := int64(m - 1); i >= 0; i-- {
		if remainders[i] < k {
			lesser = append(lesser, i)
		}
	}
	ans := int64(0)
	p1 := 0
	for i := int64(0); i < n; i++ {
		r := a[i] % m
		if remainders[r] > k {
			remainders[r]--
			steps := lesser[p1] - r
			if r > lesser[p1] {
				steps = m - r + lesser[p1]
			}
			ans += steps
			a[i] += steps
			remainders[lesser[p1]]++
			if remainders[lesser[p1]] == k {
				p1++
			}
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, index int64
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var indexes [][]int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	indexes = make([][]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		r := a[i] % m
		remainders[r]++
		indexes[r] = append(indexes[r], i)
	}

	ans := int64(0)
	q := make([]rem, 0)
	for i := int64(0); i < 2*m; i++ {
		r := i % m
		for l := len(indexes[r]); remainders[r] > k; l-- {
			q = append(q, rem{r: r, index: indexes[r][l-1]})
			indexes[r] = indexes[r][:l-1]
			remainders[r]--
		}
		for l := len(q); remainders[r] < k && l > 0; l-- {
			remainders[r]++
			t := q[l-1]
			q = q[:l-1]
			step := (m + i - t.r) % m
			ans += step
			a[i] += step
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}


You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. You want to split it into exactly $$$k$$$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to rearrange (shuffle) the elements of a given array. Each of the $$$n$$$ elements of the array $$$a$$$ must belong to exactly one of the $$$k$$$ subsegments.Let's see some examples of dividing the array of length $$$5$$$ into $$$3$$$ subsegments (not necessarily with odd sums): $$$[1, 2, 3, 4, 5]$$$ is the initial array, then all possible ways to divide it into $$$3$$$ non-empty non-intersecting subsegments are described below:  $$$[1], [2], [3, 4, 5]$$$;  $$$[1], [2, 3], [4, 5]$$$;  $$$[1], [2, 3, 4], [5]$$$;  $$$[1, 2], [3], [4, 5]$$$;  $$$[1, 2], [3, 4], [5]$$$;  $$$[1, 2, 3], [4], [5]$$$. Of course, it can be impossible to divide the initial array into exactly $$$k$$$ subsegments in such a way that each of them will have odd sum of elements. In this case print "NO". Otherwise, print "YES" and any possible division of the array. See the output format for the detailed explanation.You have to answer $$$q$$$ independent queries.

The first line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of subsegments, respectively. The second line of the query contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all queries does not exceed $$$2 \cdot 10^5$$$ ($$$\sum n \le 2 \cdot 10^5$$$).

For each query, print the answer to it. If it is impossible to divide the initial array into exactly $$$k$$$ subsegments in such a way that each of them will have odd sum of elements, print "NO" in the first line. Otherwise, print "YES" in the first line and any possible division of the array in the second line. The division can be represented as $$$k$$$ integers $$$r_1$$$, $$$r_2$$$, ..., $$$r_k$$$ such that $$$1 \le r_1 < r_2 < \dots < r_k = n$$$, where $$$r_j$$$ is the right border of the $$$j$$$-th segment (the index of the last element that belongs to the $$$j$$$-th segment), so the array is divided into subsegments $$$[1; r_1], [r_1 + 1; r_2], [r_2 + 1, r_3], \dots, [r_{k - 1} + 1, n]$$$. Note that $$$r_k$$$ is always $$$n$$$ but you should print it anyway.

package main

import (
	"bufio"
	"os"
	"runtime"
	"strconv"
)

/* solution */

func solve() {
	q := readInt()
	for i := 0; i < q; i++ {
		solveOne()
	}
}

func solveOne() {
	n, k := readInt(), readInt()
	sum := 0
	cnt := 0
	ans := make([]int, k)
	for i := 0; i < n; i++ {
		sum = (sum + readInt()) % 2
		if cnt == k-1 {
			continue
		}
		if sum == 1 {
			sum = 0
			ans[cnt] = i + 1
			cnt++
		}
	}
	if cnt == k-1 && sum == 1 {
		println("YES")
		for i := 0; i < k-1; i++ {
			printInt(ans[i])
		}
		printInt(n)
		println("")
	} else {
		println("NO")
	}
}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func read() string {
	reader.Scan()
	return reader.Text()
}

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

func println(s string) {
	if len(s) > 0 {
		writer.WriteString(s)
	}
	writer.WriteString("\n")
}

func print(s string) {
	if len(s) > 0 {
		writer.WriteString(s)
	}
	writer.WriteString(" ")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

package main

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

func main() {
	var n, s, q, d int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	for i := int64(0); i < q; i++ {

		fmt.Fscanln(scr, &n, &s)
		a := make([]int64, n)
		sum := int64(0)

		for i := int64(0); i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &d)

		res := make([]int64, 0)
		sumRes := int64(0)

		for x, y := range a {
			sumRes += int64(y)
			if sumRes%2 == 1 && s > 2 {
				res = append(res, int64(x+1))
				sum -= sumRes
				sumRes = 0
				s--
			} else if sumRes%2 == 1 && s == 2 && int64(x+1) < n {
				if (sum-sumRes)%2 == 1 {
					res = append(res, int64(x+1))
					res = append(res, n)
					s = 0
					break
				}
			}
		}
		if s == 0 {
			fmt.Println("YES")
			for _, y := range res {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else if s == 1 {
			if sum%2 == 1 {
				fmt.Println("YES")
				fmt.Println(n)
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Fscanln(scr, &n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &x)
		res1 := make([]int64, 0)

		if k >= 2 {
			for x, y := range a {
				cnt += y

				if k == 2 && cnt%2 != 0 && x < len(a)-1 {
					if (sum-cnt)%2 != 0 {
						res = 5
						res1 = append(res1, int64(x+1))
						res1 = append(res1, int64(len(a)))
						break
					}
				} else {
					if cnt%2 != 0 {
						res1 = append(res1, int64(x+1))
						sum -= cnt
						cnt = 0
						k--
					}
				}
			}
		} else {
			if sum%2 != 0 {
				res = 5
				res1 = append(res1, int64(len(a)))
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for x, y := range res1 {
				if x == len(res1)-1 {
					fmt.Printf("%d\n", y)
				} else {
					fmt.Printf("%d ", y)
				}
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {

	var testCase int
	reader := bufio.NewReader(os.Stdin)

	_, _ = fmt.Fscanf(reader, "%d\n", &testCase)

	for testCase > 0 {
		testCase -= 1
		var (
			totalNum int
			subNum   int
			crt      int
		)
		_, _ = fmt.Fscanf(reader, "%d %d\n", &totalNum, &subNum)
		nums := make([]int, totalNum)
		odds := make([]string, totalNum)

		for i := 0; i < totalNum; i += 1 {
			_, _ = fmt.Fscanf(reader, "%d", &nums[i])
			if nums[i]%2 == 1 {
				odds[crt] = strconv.Itoa(i + 1)
				crt += 1
			}
		}
		_, _ = fmt.Fscanf(reader, "\n")

		if crt < subNum {
			fmt.Println("NO")
			continue
		}

		if (crt-subNum)%2 == 1 {
			fmt.Println("NO")
			continue
		}

		fmt.Println("YES")
		odds = append(odds[:subNum-1], strconv.Itoa(totalNum))
		fmt.Println(strings.Join(odds, " "))
	}

}

package main

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

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

	var q int
	fmt.Fscanf(input, "%d\n", &q)

	for i := 0; i < q; i++ {
		var n, k int
		fmt.Fscanf(input, "%d %d\n", &n, &k)

		var count int
		var ans []int
		for j := 0; j < n; j++ {
			var x int
			fmt.Fscanf(input, "%d", &x)
			if x%2 == 1 {
				if len(ans) == k-1 {
					count++
				} else {
					ans = append(ans, j+1)
				}
			}
		}
		fmt.Fscanf(input, "\n")
		if count%2 == 1 {
			fmt.Println("YES")
			ans = append(ans, n)
			for j := range ans {
				fmt.Printf("%d", ans[j])
				if j < len(ans)-1 {
					fmt.Printf(" ")
				}
			}
			fmt.Printf("\n")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var num int

	_, err := fmt.Fscanf(input, "%d\n", &num)
	if err != nil {
	}

	for num > 0 {
		num -= 1
		var n, k, j int

		_, err := fmt.Fscanf(input, "%v %v\n", &n, &k)
		if err != nil {
		}

		var arr = make([]int, n)
		var result = make([]string, n)

		for i := 0; i < n; i++ {
			_, err := fmt.Fscanf(input, "%v", &arr[i])
			if err != nil {
			}

			if arr[i]%2 == 1 {
				result[j] = strconv.Itoa(i + 1)
				j++
			}
		}
		_, err = fmt.Fscanf(input, "\n")
		if err != nil {
		}

		if j < k || (j-k)%2 != 0 {
			fmt.Println("NO")
			continue
		}
		fmt.Println("YES")

		total := result[:k-1]
		total = append(total, strconv.Itoa(n))

		fmt.Println(strings.Join(total, " "))
	}

}

package main

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

func isOdd(a int) bool {
	if a%2 == 1 {
		return true
	}
	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	q := 0
	fmt.Fscan(in, &q)
	for ; q > 0; q-- {
		n, k := 0, 0
		cntOdd := 0
		fmt.Fscan(in, &n, &k)
		as := make([]int, n)
		// even = filler -> present or not they don't affect the outcome
		for i := range as {
			fmt.Fscan(in, &as[i])
			if isOdd(as[i]) {
				cntOdd++
			}
		}
		restOdd := cntOdd - (k - 1)
		if k > cntOdd ||
			// too many odds -> reduce to a single one ( require odd number of exceeding odds )
			cntOdd > k && !isOdd(restOdd) {
			fmt.Fprintln(out, "NO")
			continue
		}
		fmt.Fprintln(out, "YES")
		subseg := cntOdd - restOdd
		i := 0
		for subseg > 0 {
			if isOdd(as[i]) {
				fmt.Fprintf(out, "%d ", i+1)
				subseg--
			}
			i++
		}
		// rest of odds
		fmt.Fprintf(out, "%d\n", n)
	}
}

package main

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

func isOdd(a int) bool {
	if a%2 == 1 {
		return true
	}
	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	// even = filler -> present or not they don't affect the outcome
	defer out.Flush()
	q := 0
	fmt.Fscan(in, &q)
	for ; q > 0; q-- {
		n, k := 0, 0
		cntOdd := 0
		fmt.Fscan(in, &n, &k)
		as := make([]int, n)
		for i := range as {
			fmt.Fscan(in, &as[i])
			if isOdd(as[i]) {
				cntOdd++
			}
		}
		restOdd := cntOdd - (k - 1)
		if k > cntOdd ||
			// too many odds -> reduce to a single one ( require odd number of exceeding odds )
			cntOdd > k && !isOdd(restOdd) {
			fmt.Fprintln(out, "NO")
			continue
		}
		fmt.Fprintln(out, "YES")
		i := 0
		// k - ( 1 last segment: the rest of odds )
		for k-1 > 0 {
			if isOdd(as[i]) {
				fmt.Fprintf(out, "%d ", i+1)
				k--
			}
			i++
		}
		// rest of odds
		fmt.Fprintf(out, "%d\n", n)
	}
}

package main

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

func isOdd(a int) bool {
	if a%2 == 1 {
		return true
	}
	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	// even = filler -> present or not they don't affect the outcome
	defer out.Flush()
	q := 0
	fmt.Fscan(in, &q)
	for ; q > 0; q-- {
		n, k := 0, 0
		cntOdd := 0
		fmt.Fscan(in, &n, &k)
		as := make([]int, n)
		for i := range as {
			fmt.Fscan(in, &as[i])
			if isOdd(as[i]) {
				cntOdd++
			}
		}
		restOdd := cntOdd - (k - 1)
		if k > cntOdd ||
			// too many odds -> reduce to a single one ( require odd number of exceeding odds )
			cntOdd > k && !isOdd(restOdd) {
			fmt.Fprintln(out, "NO")
			continue
		}
		fmt.Fprintln(out, "YES")
		subseg := cntOdd - restOdd
		i := 0
		for subseg > 0 {
			if isOdd(as[i]) {
				fmt.Fprintf(out, "%d ", i+1)
				subseg--
			}
			i++
		}
		// rest of odds
		fmt.Fprintf(out, "%d\n", n)
	}
}

package main

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

func main() {

	//stdin, err := os.Open("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)

	var q int
	fmt.Fscanf(reader, "%d\n", &q)

	for i := 0; i < q; i++ {
		var n, k, odd int
		r := make([]int, 0)
		fmt.Fscanf(reader, "%d %d\n", &n, &k)
		for j := 0; j < n; j++ {
			var a int64
			fmt.Fscanf(reader, "%d", &a)
			if a%2 == 1 {
				odd++
				r = append(r, j)
			}
		}
		fmt.Fscanf(reader, "\n")
		if odd < k {
			fmt.Fprintf(writer, "NO\n")
		} else {
			if odd-k > 0 && (odd-k)%2 == 1 {
				fmt.Fprintf(writer, "NO\n")
			} else {
				fmt.Fprintf(writer, "YES\n")
				for j := 0; j < k; j++ {
					if k-1 == j {
						fmt.Fprintf(writer, "%d ", n)
					} else {
						fmt.Fprintf(writer, "%d ", r[j]+1)
					}
				}
				fmt.Fprintf(writer, "\n")
			}
		}
	}

	writer.Flush()
}

// Author: sighduck
// URL: https://codeforces.com/contest/1196/problem/B

package main

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

type Solution struct {
	Exists bool
	Array  []int
}

func readArray(size int, reader *bufio.Reader) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	fmt.Fscanf(reader, "\n")
	return a
}

func printSolution(solution Solution, writer *bufio.Writer) {
	if solution.Exists {
		fmt.Fprintf(writer, "YES\n")
		for _, elem := range solution.Array {
			fmt.Fprintf(writer, "%d ", elem)
		}
		fmt.Fprintf(writer, "\n")
	} else {
		fmt.Fprintf(writer, "NO\n")
	}
}

func lastXOdd(a []int, x int, odd int) []int {
	array := []int{}
	for i, elem := range a {
		if elem%2 == 1 && odd > x {
			odd -= 1
		} else if elem%2 == 1 {
			array = append(array, i+1)
		}
	}
	return array
}

func Solve(n int, k int, a []int) Solution {
	oddCount := 0
	for _, elem := range a {
		if elem%2 == 1 {
			oddCount += 1
		}
	}
	if oddCount < k {
		return Solution{Exists: false}
	} else if (oddCount-k)%2 == 0 {
		arr := lastXOdd(a, k, oddCount)
		arr[k-1] = n
		return Solution{Exists: true, Array: arr}
	}
	return Solution{Exists: false}
}

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

	var q int
	fmt.Fscanf(reader, "%d\n", &q)
	for i := 0; i < q; i++ {
		var n, k int
		fmt.Fscanf(reader, "%d %d\n", &n, &k)
		a := readArray(n, reader)
		solution := Solve(n, k, a)
		printSolution(solution, writer)
	}
}

package main

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

func main() {
	var n, s, q, d int

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	for i := 0; i < q; i++ {

		fmt.Fscanln(scr, &n, &s)
		a := make([]int, n)
		sum := 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &d)

		res := make([]int, 0)
		sumRes := 0

		for x, y := range a {
			sumRes += y
			if sumRes%2 == 1 && s > 2 {
				res = append(res, x+1)
				sum -= sumRes
				sumRes = 0
				s--
			} else if sumRes%2 == 1 && s == 2 && x+1 < n {
				if (sum-sumRes)%2 == 1 {
					res = append(res, x+1)
					res = append(res, n)
					s = 0
					break
				}
			}
		}
		if s == 0 {
			fmt.Println("YES")
			for _, y := range res {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var n, s, q, d int

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	for i := 0; i < q; i++ {

		fmt.Fscanln(scr, &n, &s)
		a := make([]int, n)
		sum := 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &d)

		res := make([]int, 0)
		sumRes := 0

		for x, y := range a {
			sumRes += y
			if sumRes%2 == 1 && s > 2 {
				res = append(res, x+1)
				sum -= sumRes
				sumRes = 0
				s--
			} else if sumRes%2 == 1 && s == 2 && x+1 < n {
				if (sum-sumRes)%2 == 1 {
					res = append(res, x+1)
					res = append(res, n)
					s = 0
					break
				}
			}
		}
		if s == 0 {
			fmt.Println("YES")
			for _, y := range res {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else if s == 1 {
			if sum%2 == 1 {
				fmt.Println("YES")
				fmt.Println(n)
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var n, s, q, d int

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	for i := 0; i < q; i++ {

		fmt.Fscanln(scr, &n, &s)
		a := make([]int, n)
		sum := 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &d)

		res := make([]int, 0)
		sumRes := 0

		for x, y := range a {
			sumRes += y
			if sumRes%2 == 1 && s > 2 {
				res = append(res, x+1)
				sum -= sumRes
				sumRes = 0
				s--
			} else if sumRes%2 == 1 && s == 2 {
				if (sum-sumRes)%2 == 1 {
					res = append(res, x+1)
					res = append(res, n)
					s = 0
					break
				}
			}
		}
		if s == 0 {
			fmt.Println("YES")
			for _, y := range res {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Scanln(&n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Scanf("%d", &a[i])
			sum += a[i]
		}
		fmt.Scanln(&x)
		res1 := make([]int64, 0)

		for x, y := range a {
			cnt += y

			if k == 2 && cnt%2 != 0 && x < len(a)-1 {
				if (sum-cnt)%2 != 0 {
					res = 5
					res1 = append(res1, int64(x+1))
					res1 = append(res1, int64(len(a)))
					break
				}
			} else {
				if cnt%2 != 0 {
					res1 = append(res1, int64(x+1))
					sum -= cnt
					cnt = 0
					k--
				}
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for x, y := range res1 {
				if x == len(res1)-1 {
					fmt.Printf("%d\n", y)
				} else {
					fmt.Printf("%d ", y)
				}
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Fscanln(scr, &n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &x)
		res1 := make([]int64, 0)

		for x, y := range a {
			cnt += y

			if k == 2 && cnt%2 != 0 && x < len(a)-1 {
				if (sum-cnt)%2 != 0 {
					res = 5
					res1 = append(res1, int64(x+1))
					res1 = append(res1, int64(len(a)))
					break
				}
			} else {
				if cnt%2 != 0 {
					res1 = append(res1, int64(x+1))
					sum -= cnt
					cnt = 0
					k--
				}
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for x, y := range res1 {
				if x == len(res1)-1 {
					fmt.Printf("%d\n", y)
				} else {
					fmt.Printf("%d ", y)
				}
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Scanln(&n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Scanf("%d", &a[i])
			sum += a[i]
		}
		fmt.Scanln(&x)
		res1 := make([]int64, 0)

		for x, y := range a {
			cnt += y

			if k == 2 && cnt%2 != 0 && x < len(a)-1 {
				if (sum-cnt)%2 != 0 {
					res = 5
					res1 = append(res1, int64(x+1))
					res1 = append(res1, int64(len(a)))
					break
				}
			} else {
				if cnt%2 != 0 {
					res1 = append(res1, int64(x+1))
					sum -= cnt
					cnt = 0
					k--
				}
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for _, y := range res1 {
				fmt.Printf("%d ", y)
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Scanln(&n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Scanf("%d", &a[i])
			sum += a[i]
		}
		fmt.Scanln(&x)
		res1 := make([]int64, 0)

		for x, y := range a {
			cnt += y

			if k == 2 && cnt%2 != 0 && x < len(a)-1 {
				if (sum-cnt)%2 != 0 {
					res = 5
					res1 = append(res1, int64(x+1))
					res1 = append(res1, int64(len(a)))
					break
				}
			} else {
				if cnt%2 != 0 {
					res1 = append(res1, int64(x+1))
					sum -= cnt
					cnt = 0
					k--
				}
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for _, y := range res1 {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var n, s, q, d int

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	for i := 0; i < q; i++ {

		fmt.Fscanln(scr, &n, &s)
		a := make([]int, n)
		sum := 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Println(a, n, s)
		fmt.Fscanln(scr, &d)

		res := make([]int, 0)
		sumRes := 0

		for x, y := range a {
			sumRes += y
			if sumRes%2 == 1 && s > 2 {
				res = append(res, x+1)
				sum -= sumRes
				sumRes = 0
				s--
			} else if sumRes%2 == 1 && s == 2 {
				if (sum-sumRes)%2 == 1 {
					res = append(res, x+1)
					res = append(res, n)
					s = 0
					break
				}
			}
		}
		if s == 0 {
			fmt.Println("YES")
			for _, y := range res {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Fscanln(scr, &n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &x)
		res1 := make([]int64, 0)

		if k > 2 {
			for x, y := range a {
				cnt += y

				if k == 2 && cnt%2 != 0 && x < len(a)-1 {
					if (sum-cnt)%2 != 0 {
						res = 5
						res1 = append(res1, int64(x+1))
						res1 = append(res1, int64(len(a)))
						break
					}
				} else {
					if cnt%2 != 0 {
						res1 = append(res1, int64(x+1))
						sum -= cnt
						cnt = 0
						k--
					}
				}
			}
		} else {
			if sum%2 != 0 {
				res = 5
				res1 = append(res1, int64(len(a)))
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for x, y := range res1 {
				if x == len(res1)-1 {
					fmt.Printf("%d\n", y)
				} else {
					fmt.Printf("%d ", y)
				}
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Scanln(&n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Scanf("%d", &a[i])
			sum += a[i]
		}
		fmt.Scanln(&x)
		res1 := make([]int64, 0)

		for x, y := range a {
			cnt += y

			if k == 2 && cnt%2 != 0 && x < len(a)-1 {
				if (sum-cnt)%2 != 0 {
					res = 5
					res1 = append(res1, int64(x+1))
					res1 = append(res1, int64(len(a)))
					break
				}
			} else {
				if cnt%2 != 0 {
					res1 = append(res1, int64(x+1))
					sum -= cnt
					cnt = 0
					k--
				}
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for _, y := range res1 {
				fmt.Printf("%d", y)
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {

	var testCase int
	reader := bufio.NewReader(os.Stdin)

	_, _ = fmt.Fscanf(reader, "%d\n", &testCase)

	for testCase > 0 {
		testCase -= 1
		var (
			totalNum int
			subNum   int
			crt      int
		)
		_, _ = fmt.Fscanf(reader, "%d %d\n", &totalNum, &subNum)
		nums := make([]int, totalNum)
		odds := make([]string, totalNum)

		for i := 0; i < totalNum; i += 1 {
			_, _ = fmt.Fscanf(reader, "%d", &nums[i])
			if nums[i]%2 == 1 {
				odds[crt] = strconv.Itoa(i + 1)
				crt += 1
			}
		}
		_, _ = fmt.Fscanf(reader, "\n")

		if crt < subNum {
			fmt.Println("NO")
			continue
		}

		if (crt-subNum)%2 == 1 {
			fmt.Println("NO")
			continue
		}

		fmt.Println("YES")
		fmt.Println(strings.Join(odds[:subNum], " "))
	}

}

package main

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

func isOdd(a int) bool {
	if a%2 == 1 {
		return true
	}
	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	// even = filler -> present or not they don't affect the outcome
	defer out.Flush()
	q := 0
	fmt.Fscan(in, &q)
	for ; q > 0; q-- {
		n, k := 0, 0
		cntOdd := 0
		fmt.Fscan(in, &n, &k)
		as := make([]int, n)
		for i := range as {
			fmt.Fscan(in, &as[i])
			if isOdd(as[i]) {
				cntOdd++
			}
		}
		restOdd := cntOdd - (k - 1)
		if k > cntOdd ||
			// too many odds -> reduce to a single one ( require odd number of exceeding odds )
			cntOdd > k && !isOdd(restOdd) {
			fmt.Fprintln(out, "NO")
			continue
		}
		fmt.Fprintln(out, "YES")
		for i, a := range as {
			if isOdd(a) {
				fmt.Fprintf(out, " %d", i+1)
			}
		}
		fmt.Fprintln(out)
	}
}

package main

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

func main() {

	//stdin, err := os.Open("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)

	var q int
	fmt.Fscanf(reader, "%d\n", &q)

	for i := 0; i < q; i++ {
		var n, k, odd int
		r := make([]int, 0)
		fmt.Fscanf(reader, "%d %d\n", &n, &k)
		for j := 0; j < n; j++ {
			var a int64
			fmt.Fscanf(reader, "%d", &a)
			if a%2 == 1 {
				odd++
				r = append(r, j)
			}
		}
		fmt.Fscanf(reader, "\n")
		if odd < k {
			fmt.Fprintf(writer, "NO\n")
		} else {
			if odd%2 == 0 {
				fmt.Fprintf(writer, "NO\n")
			} else {
				fmt.Fprintf(writer, "YES\n")
				for j := 0; j < k; j++ {
					if k-1 == j {
						fmt.Fprintf(writer, "%d ", n)
					} else {
						fmt.Fprintf(writer, "%d ", r[j]+1)
					}
				}
				fmt.Fprintf(writer, "\n")
			}
		}
	}

	writer.Flush()
}

package main

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

func main() {

	//stdin, err := os.Open("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)

	var q int
	fmt.Fscanf(reader, "%d\n", &q)

	for i := 0; i < q; i++ {
		var n, k, odd int
		r := make([]int, 0)
		fmt.Fscanf(reader, "%d %d\n", &n, &k)
		for j := 0; j < n; j++ {
			var a int64
			fmt.Fscanf(reader, "%d", &a)
			if a%2 == 1 {
				odd++
				r = append(r, j)
			}
		}
		fmt.Fscanf(reader, "\n")
		if odd < k {
			fmt.Fprintf(writer, "NO\n")
		} else {
			if odd%2 == 0 {
				fmt.Fprintf(writer, "NO\n")
			} else {
				fmt.Fprintf(writer, "YES\n")
				for j := 0; j < k; j++ {
					fmt.Fprintf(writer, "%d ", r[j]+1)
				}
				fmt.Fprintf(writer, "\n")
			}
		}
	}

	writer.Flush()
}


Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at the school, then Arya will beat all present opponents. Otherwise, if all opponents are present, then they will beat Arya.For each opponent Arya knows his schedule — whether or not he is going to present on each particular day. Tell him the maximum number of consecutive days that he will beat all present opponents.Note, that if some day there are no opponents present, Arya still considers he beats all the present opponents.

The first line of the input contains two integers n and d (1 ≤ n, d ≤ 100) — the number of opponents and the number of days, respectively. The i-th of the following d lines contains a string of length n consisting of characters '0' and '1'. The j-th character of this string is '0' if the j-th opponent is going to be absent on the i-th day.

Print the only integer — the maximum number of consecutive days that Arya will beat all present opponents.

NoteIn the first and the second samples, Arya will beat all present opponents each of the d days.In the third sample, Arya will beat his opponents on days 1, 3 and 4 and his opponents will beat him on days 2 and 5. Thus, the maximum number of consecutive winning days is 2, which happens on days 3 and 4.

package main

import (
	"fmt"
)

func main() {
	var n, d int;

	if c, err := fmt.Scanf("%d %d\n", &n, &d); c != 2 || err != nil {
		panic("invalid input")
	}

	var line string
	maxWinLen, winLen := 0, 0;

	for i := 0; i < d; i++ {
		fmt.Scanln(&line)

		if isWin(line, n) {
			winLen++;

			if winLen > maxWinLen {
				maxWinLen = winLen;
			}
		} else {
			winLen = 0;
		}
	}

	fmt.Println(maxWinLen)
}

func isWin(line string, n int) bool {
	for j := 0; j < n; j++ {
		if line[j] != '1' {
			return true;
		}
	}

	return false;
}

package main

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

var (
	scan   = fmt.Scan
	writer = bufio.NewWriter(os.Stdout)
	print  = writer.WriteString
)

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

func main() {

	var ans int
	var n, m int
	scan(&m, &n)
	var cnt int
	for i := 1; i <= n; i++ {
		var ok = false
		var s string
		scan(&s)
		for i := 0; i < len(s); i++ {
			if s[i] == '0' {
				ok = true
				break
			}
		}
		if ok == true {
			cnt++
		} else {
			cnt = 0
		}
		ans = max(ans, cnt)
	}
	fmt.Println(ans)
}

package main

import "fmt"

func main() {
	var n, d int
	var s string
	max_wins := 0
	wins := 0
	fmt.Scan(&n, &d)
	for i := 0; i < d; i++ {
		flag := false
		fmt.Scan(&s)
		for j := 0; j < n; j++ {
			if s[j] == '0' {
				wins++
				flag = true
				break
			}
		}
		if !flag {
			if wins > max_wins {
				max_wins = wins
			}
			wins = 0
		}
	}
	if wins > max_wins {
		max_wins = wins
	}
	fmt.Println(max_wins)
}

package main

import "fmt"

func main(){
    var(
       n int
       d int
    )
    fmt.Scanf("%d %d\n",&n,&d)
    var ans int
    ans=-1
    var str [104]string
    for i:=0; i<d; i++ {
	var ss string
	fmt.Scanf("%s\n",&ss)
	str[i]=ss
    }
    count:=0
    for i:=0; i<d; i++ {
	var ones int
	ones = 0
	for j:=0; j<n; j++ {
	    if str[i][j]==49 {
		ones+=1
	    }
	}
	if ones!=n{
	    count++;
	}else {
	    if ans < count{
		ans=count
	    }
		count=0
	}
	if i==d-1{
	    if ans < count{
		ans=count
	    }
	}
    }
    fmt.Printf("%d\n",ans)
}

package main

import "fmt"

func main() {
	var n, d int
	fmt.Scanln(&n, &d)

	all := ""
	for i := 0; i < n; i++ {
		all = fmt.Sprintf("%s1", all)
	}

	var current, best int
	for i := 0; i < d; i++ {
		var line string
		fmt.Scanln(&line)
		if line != all {
			current++
			if best < current {
				best = current
			}
		} else {
			current = 0
		}
	}

	fmt.Println(best)
}

package main

import (
    "fmt"
)

func main() {
    var s string
    var n, d, curr, max int

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

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

        var win = false
        for j := 0; j < n; j++ {
            win = win || (s[j] == '0')
        }

        if curr++; !win {
            curr = 0
        }

        if curr > max {
            max = curr
        }
    }

    fmt.Println(max)
}

package main

import (
	"fmt"
	"strings"
)

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

	var s string
	days := 0
	max := 0
	for i := 0; i < d; i++ {
		fmt.Scan(&s)
		if strings.Count(s, "1") < n {
			days++
			if days > max {
				max = days
			}
		} else {
			days = 0
		}
	}

	fmt.Println(max)
}

package main

import "fmt"

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

func main() {
    var buff string;
    var n, d int;
    fmt.Scanf("%d%d\n", &n, &d);
    ans, cnt := 0, 0;

    for i := 0; i < d; i++ {
        fmt.Scanf("%s\n", &buff);
        //fmt.Println("buff =", buff);
        flag := false;
        for j := 0; j < n; j++ {
            if buff[j] == '0' {
                flag = true;
                break;
            }
        }
        if flag {
            cnt += 1;
            ans = max(ans, cnt);
            //fmt.Printf("ans = %d\n", ans);
        } else {
            cnt = 0;
            //fmt.Printf("clear: %d\n", i);
        }
    }

    fmt.Printf("%d\n", ans);
}

package main

import "fmt"

func main() {
    var n, d int
    fmt.Scan(&n, &d)
    presents := make([]int, d+1)
    for i:=0; i<d; i++ {
        var s string
        fmt.Scan(&s)
        var allPresent bool = true
        for _, c := range s {
            if c == '0' {
                allPresent = false
            }
        }
        if allPresent {
            presents[i] = 1
        }
    }
    presents[d] = 1
    maxDays := 0
    curDays := 0
    for i:=0; i <= d; i++ {
        if presents[i] == 0 {
            curDays++
            if maxDays < curDays {
                maxDays = curDays
            }
        } else {
            curDays = 0
        }
    }
    fmt.Print(maxDays)
}

package main

import (
	"fmt"
)

func check(s string) bool {
	for _, v := range s {
		if v == '0' {
			return true
		}
	}
	return false
}
func main() {
	var n, d int
	fmt.Scan(&n, &d)
	mx := 0
	cont := 0
	for i := 0; i < d; i++ {
		var s string
		fmt.Scan(&s)
		if check(s) {
			cont++
			mx = max(mx, cont)
		} else {
			cont = 0
		}

	}
	fmt.Println(mx)
}
func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

package main

import "fmt"
import "bufio"
import "os"
import "strings"
import "strconv"

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	n, _ := strconv.ParseInt(s[0], 10, 64)

	var i int64
	comp := ""
	for i = 0; i < n; i++ {
		comp += "1"
	}
	c := 0
	mc := 0
	for scanner.Scan() {
		s := scanner.Text()
		if s != comp {
			c++
		} else {
			if c > mc {
				mc = c
			}
			c = 0
		}
	}
	if c > mc {
		mc = c
	}
	fmt.Printf("%d", mc)
}

package main

import (
	"fmt"
)

func main() {
	var n,d int
	fmt.Scan(&n,&d)
	var v,l int
	var x string
	for i :=0;i<n;i++ {
		x += "1"
	}
	for i:=0;i<d;i++{
		var s string
		fmt.Scan(&s)
		if  s != x{
			l++
		} else {
			l = 0
		}
		if l>v {
			v = l
		}
	}
	fmt.Println(v)
}

package main

import "fmt"

func main(){
    var(
       n int
       d int
    )
    fmt.Scanf("%d %d\n",&n,&d)
    var ans int
    ans=-1
    var str [104]string
    for i:=0; i<d; i++ {
	var ss string
	fmt.Scanf("%s\n",&ss)
	str[i]=ss
    }
    count:=0
    for i:=0; i<d; i++ {
	var ones int
	ones = 0
	for j:=0; j<n; j++ {
	    if str[i][j]==49 {
		ones+=1
	    }
	}
	if ones!=n{
	    count++;
	}else {
	    if ans < count{
		ans=count
		count=0
	    }
	}
	if i==d-1{
	    if ans < count{
		ans=count
	    }
	}
    }
    fmt.Printf("%d\n",ans)
}

package main

import "fmt"

func main() {
    var n, d int
    fmt.Scan(&n, &d)
    presents := make([]int, d+1)
    for i:=0; i<n; i++ {
        var s string
        fmt.Scan(&s)
        for d, c := range s {
            if c == '1' {
                presents[d]++
            }
        }
    }
    for i:=0; i<d; i++ {
        presents[i] /= d
    }
    presents[d] = 1
    maxDays := 0
    curDays := 0
    for i:=0; i <= d; i++ {
        if presents[i] == 0 {
            curDays++
            if maxDays < curDays {
                maxDays = curDays
            }
        } else {
            curDays = 0
        }
    }
    fmt.Print(maxDays)
}

package main

import "fmt"

func main() {
    var n, d int
    fmt.Scan(&n, &d)
    presents := make([]int, d+1)
    for i:=0; i<n; i++ {
        var s string
        fmt.Scan(&s)
        for d, c := range s {
            if c == '1' {
                presents[d]++
            }
        }
    }
    for i:=0; i<d; i++ {
        presents[i] /= d
    }
    presents[d] = 1
    maxDays := 0
    curDays := 0
    for i:=0; i <= d; i++ {
        if presents[i] == 0 {
            curDays++
            if maxDays < curDays {
                maxDays = curDays
            }
        } else {
            curDays = 0
        }
    }
}

package main

import (
	"fmt"
	"strconv"
	"math"
)

func main() {
	var n,d int
	fmt.Scan(&n,&d)
	var v,l int
	for i:=0;i<d;i++{
		var s string
		fmt.Scan(&s)
		j,_ := strconv.ParseInt(s,2,64)
		if  j != int64(math.Pow(2,float64(n)))-1 {
			l++
		} else {
			l = 0
		}
		if l>v {
			v = l
		}
	}
	fmt.Println(v)
}