package main

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

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

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

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

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

		found := false
		for i := 0; i < 5 && !found; i++ {
			for j := i + 1; j < 5 && !found; j++ {
				ic, jc, bc := 0, 0, 0
				for k := 0; k < n; k++ {
					if arr[k][i] == 1 && arr[k][j] == 1 {
						bc++
					} else if arr[k][i] == 1 {
						ic++
					} else if arr[k][j] == 1 {
						jc++
					} else {
						break
					}
				}

				if ic+jc+bc == n && (ic+bc) >= n/2 && (jc+bc) >= n/2 {
					found = true
					break
				}

			}
		}

		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var n int

var st [][5]int

var days [5][]bool

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		st = make([][5]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(r, &st[j][0], &st[j][1], &st[j][2], &st[j][3], &st[j][4])
		}

		ans := solve()
		fmt.Println(ans)
	}
}

func solve() string {

	for i := 0; i < 5; i++ {
		days[i] = make([]bool, n)
	}

	for i := 0; i < n; i++ {
		if st[i][0] == 1 {
			days[0][i] = true
		}
		if st[i][1] == 1 {
			days[1][i] = true
		}
		if st[i][2] == 1 {
			days[2][i] = true
		}
		if st[i][3] == 1 {
			days[3][i] = true
		}
		if st[i][4] == 1 {
			days[4][i] = true
		}
	}

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

		d1 := days[i]
		for j := i + 1; j < 5; j++ {
			d2 := days[j]

			one := 0
			two := 0
			both := 0

			for k := 0; k < n; k++ {
				if d1[k] {
					one++
				}
				if d2[k] {
					two++
				}
				if d1[k] || d2[k] {
					both++
				}
			}

			if one >= n/2 && two >= n/2 && both == n {
				return "YES"
			}
		}
	}

	return "NO"
}

package main

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

var (
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

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

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

func _int() int {
	s := _string()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func _int64() int64 {
	s := _string()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func _string() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := _int(); t > 0; t-- {
		n := _int()
		students := make([][5]int, n)
		for i := range students {
			for j := range students[i] {
				students[i][j] = _int()
			}
		}
		printf("%s\n", sol(n, students))
	}
}

func sol(n int, students [][5]int) string {
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			if can(n, students, i, j) {
				return "YES"
			}
		}
	}
	return "NO"
}

func can(n int, students [][5]int, d1, d2 int) bool {
	canD1 := 0
	canD2 := 0
	for i := range students {
		if !(students[i][d1] == 1 || students[i][d2] == 1) {
			return false
		}
		if students[i][d1] == 1 {
			canD1++
		}
		if students[i][d2] == 1 {
			canD2++
		}
	}
	return canD1 >= n/2 && canD2 >= n/2
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d\n", &n)
		s := make([][5]byte, n)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d %d %d %d %d\n", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4])
		}
		found := false
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int
				for q := 0; q < n; q++ {
					if s[q][i] == 0 && s[q][j] == 0 {
						rs = false
						break
					}
					if s[q][i] == 1 && s[q][j] == 0 {
						onlyi++
					}
					if s[q][i] == 0 && s[q][j] == 1 {
						onlyj++
					}
					if s[q][i] == 1 && s[q][j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var input io.Reader = bufio.NewReader(os.Stdin)
var output io.Writer = bufio.NewWriter(os.Stdout)

var t, n int
var a [1005][5]int

func testcase() bool {
	fmt.Fscan(input, &n)

	for i := 0; i < n; i++ {
		for j := 0; j < 5; j++ {
			fmt.Fscan(input, &a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			can := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						can = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			if cnt[0] < cnt[1] {
				tmp := cnt[1] - cnt[0]
				cnt[0] += tmp
				cnt[2] -= tmp
			} else {
				tmp := cnt[0] - cnt[1]
				cnt[1] += tmp
				cnt[2] -= tmp
			}
			if cnt[2] < 0 {
				can = false
			}
			cnt[0] += cnt[2] / 2
			cnt[1] += cnt[2] / 2
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && can {
				return true
			}
		}
	}
	return false
}

func main() {
	fmt.Fscan(input, &t)
	for ; t > 0; t-- {
		cur := testcase()
		if cur {
			fmt.Fprint(os.Stdout, "YES\n")
		} else {
			fmt.Fprint(os.Stdout, "NO\n")
		}
	}

}

package main

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

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

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

var t, n int
var a [1005][5]int

func testcase() bool {
	// scanf("%d\n", &n)
	fmt.Fscan(input, &n)
	for i := 0; i < n; i++ {
		for j := 0; j < 5; j++ {
			// scanf("%d ", &a[i][j])
			fmt.Fscan(input, &a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			can := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						can = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			if cnt[0] < cnt[1] {
				tmp := cnt[1] - cnt[0]
				cnt[0] += tmp
				cnt[2] -= tmp
			} else {
				tmp := cnt[0] - cnt[1]
				cnt[1] += tmp
				cnt[2] -= tmp
			}
			if cnt[2] < 0 {
				can = false
			}
			cnt[0] += cnt[2] / 2
			cnt[1] += cnt[2] / 2
			// fmt.Println(i, j, cnt)
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && can {
				return true
			}
		}
	}
	return false
}

func main() {
	// scanf("%d\n", &t)
	fmt.Fscan(input, &t)
	for ; t > 0; t-- {
		// writer.Flush()
		cur := testcase()
		// fmt.Println(cur)
		if cur {
			// printf("YES\n")
			fmt.Println("YES")
		} else {
			// printf("NO\n")
			fmt.Println("NO")
		}
		// writer.Flush()
	}

}

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

var t, n int
var a [1005][5]int

func testcase() bool {
	// scanf("%d\n", &n)
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		for j := 0; j < 5; j++ {
			// scanf("%d ", &a[i][j])
			fmt.Scan(&a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			can := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						can = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			if cnt[0] < cnt[1] {
				tmp := cnt[1] - cnt[0]
				cnt[0] += tmp
				cnt[2] -= tmp
			} else {
				tmp := cnt[0] - cnt[1]
				cnt[1] += tmp
				cnt[2] -= tmp
			}
			if cnt[2] < 0 {
				can = false
			}
			cnt[0] += cnt[2] / 2
			cnt[1] += cnt[2] / 2
			// fmt.Println(i, j, cnt)
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && can {
				return true
			}
		}
	}
	return false
}

func main() {
	// scanf("%d\n", &t)
	fmt.Scan(&t)
	for ; t > 0; t-- {
		// writer.Flush()
		cur := testcase()
		// fmt.Println(cur)
		if cur {
			// printf("YES\n")
			fmt.Println("YES")
		} else {
			// printf("NO\n")
			fmt.Println("NO")
		}
		// writer.Flush()
	}

}

package main

import (
	"fmt"
)

var t, n int
var a [1005][5]int

func testcase() bool {
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		for j := 0; j < 5; j++ {
			fmt.Scan(&a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			can := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						can = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			if cnt[0] < cnt[1] {
				tmp := cnt[1] - cnt[0]
				cnt[0] += tmp
				cnt[2] -= tmp
			} else {
				tmp := cnt[0] - cnt[1]
				cnt[1] += tmp
				cnt[2] -= tmp
			}
			if cnt[2] < 0 {
				can = false
			}
			cnt[0] += cnt[2] / 2
			cnt[1] += cnt[2] / 2
			// fmt.Println(i, j, cnt)
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && can {
				return true
			}
		}
	}
	return false
}

func main() {
	fmt.Scan(&t)
	for ; t > 0; t-- {
		cur := testcase()
		if cur {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

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)

		c := make([][5]int, n)
		for i := 0; i < n; i++ {
			for j := 0; j < 5; j++ {
				fmt.Fscan(in, &c[i][j])
			}
		}

		var isValid bool
		for i := 0; i < 5; i++ {
			for j := 0; j < 5; j++ {
				if i == j {
					continue
				}

				var c1, c2, cx int
				for _, p := range c {
					if p[i] == 1 {
						c1++
					}

					if p[j] == 1 {
						c2++
					}

					if p[i] == 0 && p[j] == 0 {
						cx++
					}
				}

				if c1 >= n/2 && c2 >= n/2 && cx == 0 {
					isValid = true
					break
				}
			}
		}

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

package main

import "fmt"

const (
	MaxN = 1005
	MaxDay = 5
)

var (
	T, n int
	a [MaxN][MaxDay]int
)

func main() {
	_, _ = fmt.Scan(&T)
	for ; T > 0; T-- {
		_, _ = fmt.Scan(&n)

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

		ans := "NO"
		for j1 := 0; j1 < MaxDay; j1++ {
			for j2 := j1 + 1; j2 < MaxDay; j2++ {
				x, y := 0, 0
				for i := 0; i < n; i++ {
					if a[i][j1] == 0 && a[i][j2] == 0 {
						x, y = 0, 0
						break
					}
					x += a[i][j1]
					y += a[i][j2]
				}
				if x >= n / 2 && y >= n / 2 {
					ans = "YES"
				}
			}
		}

		fmt.Println(ans)
	}
}

package main

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

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

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

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

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

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

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

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

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

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

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

		}
		return initial
	}
}

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

		}
		return m
	}
}

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

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

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

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

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

	return
}

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

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

	return num
}

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

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

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

var t int

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

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

		bir := make([]int, 0)
		iki := make([]int, 0)
		uc := make([]int, 0)
		dort := make([]int, 0)
		bas := make([]int, 0)

		for i := 1; i < n+1; i++ {
			var b, ii, u, d, bs int
			fmt.Fscan(input, &b, &ii, &u, &d, &bs)
			if b == 1 {
				bir = append(bir, i)
			}
			if ii == 1 {
				iki = append(iki, i)
			}
			if u == 1 {
				uc = append(uc, i)
			}
			if d == 1 {
				dort = append(dort, i)
			}
			if bs == 1 {
				bas = append(bas, i)
			}

		}

		l := n / 2
		Bigg := make([][]int, 0)
		if len(bir) >= l {
			Bigg = append(Bigg, bir)
		}
		if len(iki) >= l {
			Bigg = append(Bigg, iki)
		}
		if len(uc) >= l {
			Bigg = append(Bigg, uc)
		}
		if len(dort) >= l {
			Bigg = append(Bigg, dort)
		}
		if len(bas) >= l {
			Bigg = append(Bigg, bas)
		}

		if len(Bigg) < 2 {
			fmt.Println("NO")
		} else {
			q := len(Bigg)
			ee := 0
			for i := 0; i < q-1; i++ {
				z := 0
				for j := i + 1; j < q; j++ {
					union := Union(Bigg[i], Bigg[j])
					if len(union) == n {
						ee = 1
						z = 1
						break
					}
				}
				if z == 1 {
					break
				}
			}
			if ee == 1 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}

}

package main

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

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

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

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

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

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

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

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

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

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

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

		}
		return initial
	}
}

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

		}
		return m
	}
}

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

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

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

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

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

	return
}

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

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

	return num
}

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

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

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

var t int

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

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

		bir := make([]int, 0)
		iki := make([]int, 0)
		uc := make([]int, 0)
		dort := make([]int, 0)
		bas := make([]int, 0)

		for i := 1; i < n+1; i++ {
			var b, ii, u, d, bs int
			fmt.Fscan(input, &b, &ii, &u, &d, &bs)
			if b == 1 {
				bir = append(bir, i)
			}
			if ii == 1 {
				iki = append(iki, i)
			}
			if u == 1 {
				uc = append(uc, i)
			}
			if d == 1 {
				dort = append(dort, i)
			}
			if bs == 1 {
				bas = append(bas, i)
			}

		}

		l := n / 2
		Bigg := make([][]int, 0)
		if len(bir) >= l {
			Bigg = append(Bigg, bir)
		}
		if len(iki) >= l {
			Bigg = append(Bigg, iki)
		}
		if len(uc) >= l {
			Bigg = append(Bigg, uc)
		}
		if len(dort) >= l {
			Bigg = append(Bigg, dort)
		}
		if len(bas) >= l {
			Bigg = append(Bigg, bas)
		}

		if len(Bigg) < 2 {
			fmt.Println("NO")
		} else {
			q := len(Bigg)
			e := 0
			for i := 0; i < q-1; i++ {
				z := 0
				for j := i + 1; j < q; j++ {
					union := Union(Bigg[i], Bigg[j])
					if len(union) == n {
						e = 1
						z = 1
						break
					}
				}
				if z == 1 {
					break
				}
			}
			if e == 1 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t int
	_, _ = fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		var n int
		_, _ = fmt.Fscan(reader, &n)
		students := make([][]rune, n)
		for i := 0; i < int(n); i++ {
			students[i] = make([]rune, 5)
			for j := range students[i] {
				_, _ = fmt.Fscan(reader, &students[i][j])
			}
		}
		can := "NO"
		for i := 0; i < 5; i++ {
			for j := 0; j < 5; j++ {
				if i == j {
					continue
				}
				days := make(map[int]map[int]bool)
				for k := 0; k < 5; k++ {
					days[k] = make(map[int]bool)
				}
				for k, v := range students {
					if v[i] != 0 {
						days[i][k] = true
					}
					if v[j] != 0 {
						days[j][k] = true
					}
				}
				len0, len1 := len(days[i]), len(days[j])
				for k := range days[i] {
					if days[i][k] && days[j][k] {
						if len0 > len1 {
							days[i][k] = false
							len0--
						} else {
							days[j][k] = false
							len1--
						}
					}
				}
				if len0 == len1 && len0 == int(n)/2 {
					can = "YES"
				}
			}
		}
		fmt.Println(can)
	}
}

package main

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

var reader = bufio.NewScanner(os.Stdin)

func rString() string {
	if !reader.Scan() {
		panic(reader.Err())
	}
	return reader.Text()
}

func rInt() int64 {
	text := rString()
	n, _ := strconv.ParseInt(text, 10, 0)
	return n
}

func main() {
	t := rInt()
	fmt.Println("t=", t)
	for ; t > 0; t-- {
		n := rInt()
		fmt.Println("n=", n)
		s := make([][5]byte, n)
		for i := int64(0); i < n; i++ {
			fmt.Scanf("%d %d %d %d %d\n", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4])
		}
		fmt.Println("s=", s)
		found := false
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int64
				for _, w := range s {
					if w[i] == 0 && w[j] == 0 {
						rs = false
						break
					}
					if w[i] == 1 && w[j] == 0 {
						onlyi++
					}
					if w[i] == 0 && w[j] == 1 {
						onlyj++
					}
					if w[i] == 1 && w[j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var reader = bufio.NewScanner(os.Stdin)

func rString() string {
	if !reader.Scan() {
		panic(reader.Err())
	}
	return reader.Text()
}

func rInt() int64 {
	text := rString()
	n, _ := strconv.ParseInt(text, 10, 0)
	return n
}

func main() {
	t := rInt()
	fmt.Println("t=", t)
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d\n", &n)
		fmt.Println("n=", n)
		s := make([][5]byte, n)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d %d %d %d %d\n", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4])
		}
		fmt.Println("s=", s)
		found := false
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int
				for _, w := range s {
					if w[i] == 0 && w[j] == 0 {
						rs = false
						break
					}
					if w[i] == 1 && w[j] == 0 {
						onlyi++
					}
					if w[i] == 0 && w[j] == 1 {
						onlyj++
					}
					if w[i] == 1 && w[j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var reader = bufio.NewScanner(os.Stdin)

func rString() string {
	if !reader.Scan() {
		panic(reader.Err())
	}
	return reader.Text()
}

func rInt() int64 {
	text := rString()
	n, _ := strconv.ParseInt(text, 10, 0)
	return n
}

func main() {
	for t := rInt(); t > 0; t-- {
		var n int
		fmt.Scanf("%d\n", &n)
		s := make([][5]byte, n)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d %d %d %d %d\n", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4])
		}
		fmt.Println("s=", s)
		found := false
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int
				for _, w := range s {
					if w[i] == 0 && w[j] == 0 {
						rs = false
						break
					}
					if w[i] == 1 && w[j] == 0 {
						onlyi++
					}
					if w[i] == 0 && w[j] == 1 {
						onlyj++
					}
					if w[i] == 1 && w[j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func rString() string {
	reader := bufio.NewScanner(os.Stdin)
	if !reader.Scan() {
		panic(reader.Err())
	}
	return reader.Text()
}

func rInt() (int64, error) {
	text := rString()
	n, _ := strconv.ParseInt(text, 10, 0)
	return n, nil
}

func main() {
	t, _ := rInt()
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d\n", &n)
		s := make([][5]byte, n)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d %d %d %d %d\n", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4])
		}
		fmt.Println("s=", s)
		found := false
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int
				for _, w := range s {
					if w[i] == 0 && w[j] == 0 {
						rs = false
						break
					}
					if w[i] == 1 && w[j] == 0 {
						onlyi++
					}
					if w[i] == 0 && w[j] == 1 {
						onlyj++
					}
					if w[i] == 1 && w[j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func rString() string {
	reader := bufio.NewScanner(os.Stdin)
	if !reader.Scan() {
		panic(reader.Err())
	}
	return reader.Text()
}

func rInt() (int64, error) {
	text := rString()
	n, _ := strconv.ParseInt(text, 10, 0)
	return n, nil
}

func main() {
	t, _ := rInt()
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d\n", &n)
		s := make([][5]byte, n)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d %d %d %d %d\n", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4])
		}
		found := false
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int
				for _, w := range s {
					if w[i] == 0 && w[j] == 0 {
						rs = false
						break
					}
					if w[i] == 1 && w[j] == 0 {
						onlyi++
					}
					if w[i] == 0 && w[j] == 1 {
						onlyj++
					}
					if w[i] == 1 && w[j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func rString() string {
	reader := bufio.NewScanner(os.Stdin)
	if !reader.Scan() {
		panic(reader.Err())
	}
	return reader.Text()
}

func rInt() (int64, error) {
	text := rString()
	n, _ := strconv.ParseInt(text, 10, 0)
	return n, nil
}

func main() {
	t, _ := rInt()
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d\n", &n)
		s := make([][5]byte, n)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d %d %d %d %d\n", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4])
		}
		found := false
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int
				for q := 0; q < n; q++ {
					if s[q][i] == 0 && s[q][j] == 0 {
						rs = false
						break
					}
					if s[q][i] == 1 && s[q][j] == 0 {
						onlyi++
					}
					if s[q][i] == 0 && s[q][j] == 1 {
						onlyj++
					}
					if s[q][i] == 1 && s[q][j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d\n", &n)
		s := make([][5]byte, n)
		for i := 0; i < n; i++ {
			for j := 0; j < 5; j++ {
				fmt.Scanf("%d", &s[i][j])
			}
		}
		found := false
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int
				for q := 0; q < n; q++ {
					if s[q][i] == 0 && s[q][j] == 0 {
						rs = false
						break
					}
					if s[q][i] == 1 && s[q][j] == 0 {
						onlyi++
					}
					if s[q][i] == 0 && s[q][j] == 1 {
						onlyj++
					}
					if s[q][i] == 1 && s[q][j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d", &n)
		s := make([][5]byte, n)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d %d %d %d %d\n", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4])
		}
		found := false
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int
				for q := 0; q < n; q++ {
					if s[q][i] == 0 && s[q][j] == 0 {
						rs = false
						break
					}
					if s[q][i] == 1 && s[q][j] == 0 {
						onlyi++
					}
					if s[q][i] == 0 && s[q][j] == 1 {
						onlyj++
					}
					if s[q][i] == 1 && s[q][j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d", &n)
		s := make([][5]byte, n)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d %d %d %d %d\n", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4])
		}
		found := true
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int
				for q := 0; q < n; q++ {
					if s[q][i] == 0 && s[q][j] == 0 {
						rs = false
						break
					}
					if s[q][i] == 1 && s[q][j] == 0 {
						onlyi++
					}
					if s[q][i] == 0 && s[q][j] == 1 {
						onlyj++
					}
					if s[q][i] == 1 && s[q][j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d", &n)
		s := make([][5]byte, n)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d %d %d %d %d\n", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4])
		}
		found := true
		for i := 0; i < 5; i++ {
			for j := i + 1; j < 5; j++ {
				rs := true
				var onlyi, onlyj, both int
				for q := 0; q < n; q++ {
					if s[q][i] == 0 && s[q][j] == 0 {
						rs = false
						break
					}
					if s[q][i] == 1 && s[q][j] == 0 {
						onlyi++
					}
					if s[q][i] == 0 && s[q][j] == 1 {
						onlyj++
					}
					if s[q][i] == 1 && s[q][j] == 1 {
						both++
					}
				}
				if !rs {
					continue
				}
				if onlyi+both < n/2 || onlyj+both < n/2 {
					continue
				}
				found = true
				break
			}
		}
		if found {
			fmt.Println("YES")
		}
		fmt.Println("NO")
	}
}

package main

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

func readInt() (int, error) {
	reader := bufio.NewReader(os.Stdin)
	var n int
	_, err := fmt.Fscan(reader, &n)
	return n, err
}

func readInt64() (int64, error) {
	reader := bufio.NewReader(os.Stdin)
	var n int
	_, err := fmt.Fscan(reader, &n)
	return int64(n), err
}

func main() {
	t, _ := readInt()
	for ; t > 0; t-- {
		n, _ := readInt64()
		fmt.Printf("%d %d\n", 1-n, n)
	}
}

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

var t, n int
var a [1005][5]int

func testcase() bool {
	scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		for j := 0; j < 5; j++ {
			scanf("%d ", &a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			can := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						can = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			if cnt[0] < cnt[1] {
				tmp := cnt[1] - cnt[0]
				cnt[0] += tmp
				cnt[2] -= tmp
			} else {
				tmp := cnt[0] - cnt[1]
				cnt[1] += tmp
				cnt[2] -= tmp
			}
			if cnt[2] < 0 {
				can = false
			}
			cnt[0] += cnt[2] / 2
			cnt[1] += cnt[2] / 2
			// fmt.Println(i, j, cnt)
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && can {
				return true
			}
		}
	}
	return false
}

func main() {
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		// writer.Flush()
		cur := testcase()
		// fmt.Println(cur)
		if cur {
			// printf("YES\n")
			fmt.Println("YES")
		} else {
			// printf("NO\n")
			fmt.Println("NO")
		}
		// writer.Flush()
	}

}

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

var t, n int
var a [1005][5]int

func testcase() bool {
	scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		for j := 0; j < 5; j++ {
			scanf("%d ", &a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			can := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						can = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			if cnt[0] < cnt[1] {
				tmp := cnt[1] - cnt[0]
				cnt[0] += tmp
				cnt[2] -= tmp
			} else {
				tmp := cnt[0] - cnt[1]
				cnt[1] += tmp
				cnt[2] -= tmp
			}
			if cnt[2] < 0 {
				can = false
			}
			cnt[0] += cnt[2] / 2
			cnt[1] += cnt[2] / 2
			// fmt.Println(i, j, cnt)
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && can {
				return true
			}
		}
	}
	return false
}

func main() {
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		// writer.Flush()
		cur := testcase()
		// fmt.Println(cur)
		if cur {
			// printf("YES\n")
			fmt.Println("YES")
		} else {
			// printf("NO\n")
			fmt.Println("NO")
		}
		// writer.Flush()
	}

}

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

var t, n int
var a [1005][5]int

func testcase() bool {
	scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		for j := 0; j < 5; j++ {
			scanf("%d ", &a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			can := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						can = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			if cnt[0] < cnt[1] {
				tmp := cnt[1] - cnt[0]
				cnt[0] += tmp
				cnt[2] -= tmp
			} else {
				tmp := cnt[0] - cnt[1]
				cnt[1] += tmp
				cnt[2] -= tmp
			}
			if cnt[2] < 0 {
				can = false
			}
			cnt[0] += cnt[2] / 2
			cnt[1] += cnt[2] / 2
			// fmt.Println(i, j, cnt)
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && can {
				return true
			}
		}
	}
	return false
}

func main() {
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		writer.Flush()
		cur := testcase()
		// fmt.Println(cur)
		if cur {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
		writer.Flush()
	}

}

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

var t, n int
var a [1005][5]int

func testcase() bool {
	scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		for j := 0; j < 5; j++ {
			scanf("%d ", &a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			can := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						can = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			if cnt[0] < cnt[1] {
				tmp := cnt[1] - cnt[0]
				cnt[0] += tmp
				cnt[2] -= tmp
			} else {
				tmp := cnt[0] - cnt[1]
				cnt[1] += tmp
				cnt[2] -= tmp
			}
			if cnt[2] < 0 {
				can = false
			}
			cnt[0] += cnt[2] / 2
			cnt[1] += cnt[2] / 2
			// fmt.Println(i, j, cnt)
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && can {
				return true
			}
		}
	}
	return false
}

func main() {
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		cur := testcase()
		// fmt.Println(cur)
		if cur {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
		writer.Flush()
	}

}

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

var t, n int
var a [1005][5]int

func testcase() bool {
	scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		for j := 0; j < 5; j++ {
			scanf("%d ", &a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			can := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						can = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			if cnt[0] < cnt[1] {
				tmp := cnt[1] - cnt[0]
				cnt[0] += tmp
				cnt[2] -= tmp
			} else {
				tmp := cnt[0] - cnt[1]
				cnt[1] += tmp
				cnt[2] -= tmp
			}
			if cnt[2] < 0 {
				can = false
			}
			cnt[0] += cnt[2] / 2
			cnt[1] += cnt[2] / 2
			// fmt.Println(i, j, cnt)
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && can {
				return true
			}
		}
	}
	return false
}

func main() {
	defer writer.Flush()
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		cur := testcase()
		if cur {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}

}

package main

import (
	"fmt"
)

var t, n int
var a [1005][5]int

func testcase() bool {
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		for j := 0; j < 5; j++ {
			fmt.Scan(&a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			cur := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						cur = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			tmp := cnt[2] / 2
			if cnt[0] < cnt[1] {
				cnt[1] += tmp
				cnt[0] += cnt[2] - tmp
			} else {
				cnt[0] += tmp
				cnt[1] += cnt[2] - tmp
			}
			// fmt.Println(i, j, cnt)
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && cur {
				return true
			}
		}
	}
	return false
}

func main() {
	fmt.Scan(&t)
	for ; t > 0; t-- {
		cur := testcase()
		if cur {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

import (
	"fmt"
)

func testcase() bool {
	var n int
	fmt.Scan(&n)
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, 5)
		for j := 0; j < 5; j++ {
			fmt.Scan(&a[i][j])
		}
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			var cnt [3]int
			cur := true
			for k := 0; k < n; k++ {
				if a[k][i] == a[k][j] {
					if a[k][i] == 0 {
						cur = false
						break
					}
					cnt[2]++
				} else {
					if a[k][i] == 1 {
						cnt[0]++
					} else {
						cnt[1]++
					}
				}
			}
			tmp := cnt[2] / 2
			if cnt[0] < cnt[1] {
				cnt[1] += tmp
				cnt[0] += cnt[2] - tmp
			} else {
				cnt[0] += tmp
				cnt[1] += cnt[2] - tmp
			}
			// fmt.Println(i, j, cnt)
			if cnt[0] == cnt[1] && cnt[0]+cnt[1] == n && cur {
				return true
			}
		}
	}
	return false
}

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		cur := testcase()
		if cur {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

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)

		c := make([][5]int, n)
		for i := 0; i < n; i++ {
			for j := 0; j < 5; j++ {
				fmt.Fscan(in, &c[i][j])
			}
		}

		var isValid bool
		for i := 0; i < 5; i++ {
			for j := 0; j < 5; j++ {
				if i == j {
					continue
				}

				var c1, c2, cx int
				for _, p := range c {
					if p[i] == 1 {
						c1++
					} else if p[j] == 1 {
						c2++
					} else if p[i] == 0 && p[j] == 0 {
						cx++
					}
				}

				if c1 >= n/2 && c2 >= n/2 && cx == 0 {
					isValid = true
					break
				}
			}
		}

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

package main

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

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)

		c := make([][]int, 5)
		for i := 0; i < n; i++ {
			for j := 0; j < 5; j++ {
				var v int
				fmt.Fscan(in, &v)

				if v == 1 {
					c[j] = append(c[j], i)
				}
			}
		}

		var isValid bool
		for i := 0; i < 5; i++ {
			if len(c[i]) < n/2 {
				continue
			}

			for j := 0; j < 5; j++ {
				if i == j || len(c[j]) < n/2 {
					continue
				}

				var tally int
				for _, v := range c[j] {
					idx := sort.SearchInts(c[i], v)
					if idx >= len(c[i]) || c[i][idx] != v {
						tally++
					}
				}

				if tally >= n/2 {
					isValid = true
					break
				}
			}
		}
		if !isValid {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

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

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)

		c := make([][]int, 5)
		for i := 0; i < n; i++ {
			for j := 0; j < 5; j++ {
				var v int
				fmt.Fscan(in, &v)

				if v == 1 {
					c[j] = append(c[j], i)
				}
			}
		}

		var isValid bool
		for i := 0; i < 4; i++ {
			if len(c[i]) < n/2 {
				continue
			}

			for j := i + 1; j < 5; j++ {
				if len(c[j]) < n/2 {
					continue
				}

				var tally int
				for _, v := range c[j] {
					idx := sort.SearchInts(c[i], v)
					if idx >= len(c[i]) || c[i][idx] != v {
						tally++
					}
				}

				if tally >= n/2 {
					isValid = true
					break
				}
			}
		}
		if !isValid {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

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)

		c := make([]int, 5)
		for i := 0; i < n; i++ {
			for j := 0; j < 5; j++ {
				var v int
				fmt.Fscan(in, &v)

				if v == 1 {
					c[j]++
				}
			}
		}

		var isValid bool
		for i := 0; i < 4; i++ {
			if c[i] < n/2 {
				continue
			}

			for j := i + 1; j < 5; j++ {
				if c[j] >= n/2 {
					isValid = true
					break
				}
			}
		}
		if !isValid {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

import "fmt"

const (
	MaxN = 1005
	MaxDay = 5
)

var (
	T, n int
	a [MaxN][MaxDay]int
)

func main() {
	_, _ = fmt.Scan(&T)
	for ; T > 0; T-- {
		_, _ = fmt.Scan(&n)

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

		ans := "NO"
		for j1 := 0; j1 < MaxDay; j1++ {
			for j2 := j1 + 1; j2 < MaxDay; j2++ {
				x, y := 0, 0
				for i := 0; i < n; i++ {
					if a[i][j1] == 0 && a[i][j2] == 0 {
						break
					}
					x += a[i][j1]
					y += a[i][j2]
				}
				if x >= n / 2 && y >= n / 2 {
					ans = "YES"
				}
			}
		}

		fmt.Println(ans)
	}
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		var n, k int
		var s string
		fmt.Fscan(in, &n, &k, &s)
		v := []int{}
		for i, c := range s {
			if c == '*' {
				v = append(v, i)
			}
		}
		res := 1
		if len(v) > 1 {
			res = 2
		}
		last := v[0]
		for i := 1; i < len(v); i++ {
			if v[i] - last > k {
				last = v[i-1]
				res++
			}
		}
		fmt.Println(res)
	}
}

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 min_int(a int, b int) int { if a < b { return a } else { return b } }
func min_int64(a int64, b int64) int64 { if a < b { return a } else { return b } }

func max_int(a int, b int) int { if a > b { return a } else { return b } }
func max_int64(a int64, b int64) int64 { if a > b { return a } else { return b } }

func main() {
	defer writer.Flush()

	var T int = 0
	scanf("%d\n", &T)

	for t := 0; t < T; t++ {

		var n int = 0
		var k int = 0
		scanf("%d %d\n", &n, &k)
		var s string
		scanf("%s\n", &s)

		res := make([]int, n)
		var index int = 0
		for i := 0; i < n; i++ {
			if s[i] == '*' {
				res[i] = 1
				index = i
				break
			}
		}

		for i := index+1; i < n; i++ {

			var max_index = -1

			for j := i; j <= min_int(n-1, i+k-1); j++ {
				if s[j] == '*' {
					max_index = j
				}
			}

			if max_index != -1 {
				res[max_index] = 1
				i = max_index
			}
		}

		for i := n-1; i >= 0; i-- {
			if s[i] == '*' && res[i] == 1 {
				break
			}

			if s[i] == '*' {
				res[i] = 1
				index = i
				break
			}
		}

		var ans int = 0
		for i := 0; i < n; i++ {
			if res[i] == 1 {
				ans = ans + 1
			}
		}
		printf("%d\n", 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 min_int(a int, b int) int { if a < b { return a } else { return b } }
func min_int64(a int64, b int64) int64 { if a < b { return a } else { return b } }

func max_int(a int, b int) int { if a > b { return a } else { return b } }
func max_int64(a int64, b int64) int64 { if a > b { return a } else { return b } }

func main() {
	defer writer.Flush()

	var T int = 0
	scanf("%d\n", &T)

	for t := 0; t < T; t++ {

		var n int = 0
		var k int = 0
		scanf("%d %d\n", &n, &k)
		var s string
		scanf("%s\n", &s)

		res := make([]int, n)
		var index int = 0
		for i := 0; i < n; i++ {
			if s[i] == '*' {
				res[i] = 1
				index = i
				// printf("index: %d\n", index)
				break
			}
		}

		for i := index+1; i < n; i++ {
			// printf("I: %d\n", i)

			var max_index = -1

			// printf("up to: %d\n", min_int(n-1, i+k-1))
			for j := i; j <= min_int(n-1, i+k-1); j++ {
				if s[j] == '*' {
					// printf("-------> j: %d\n", j)
					max_index = j
				}
			}

			if max_index != -1 {
				// printf("setting: %d\n", max_index)
				res[max_index] = 1
				i = max_index
			}
			// printf("New index: %d\n", i)
		}

		for i := n-1; i >= 0; i-- {
			if s[i] == '*' && res[i] == 1 {
				break
			}

			if s[i] == '*' {
				// printf("--> setting: %d\n", i)
				res[i] = 1
				index = i
				break
			}
		}

		var ans int = 0
		for i := 0; i < n; i++ {
			if res[i] == 1 {
				ans = ans + 1
			}
			// printf("%d ", res[i])
		}
		// printf("\n")
		printf("%d\n", ans)

	}

}

package main

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

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

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n, k int
		var s []byte
		Fscan(in, &n, &k, &s)

		ans := 1
		start := bytes.Index(s, []byte{'*'})
		end := bytes.LastIndex(s, []byte{'*'})
		if start != end {
			ans = 2
		}
		for i := start; i + k < end; {
			i += bytes.LastIndex(s[i+1:i+k+1], []byte{'*'}) + 1
			ans++
		}
		Fprintln(out, ans)

	}
}

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

func decomposition(n int) []int {
	var res []int
	for p := 2; n >= p * p;  {
		if n % p == 0 {
			res = append(res, p)
			n /= p
		} else {
			p++
		}
	}
	if n > 1 {
		res = append(res, n)
	}
	return res
}

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

package main

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

func main() {

	input := bufio.NewReader(os.Stdin)
	var testCases int
	fmt.Fscan(input, &testCases)

	for testCases > 0 {
		testCases--
		var str1 string
		var n, k int
		result := 1
		fmt.Fscan(input, &n, &k, &str1)
		i := getFirstStarIndex(str1)
		for 0 < 1 {
			j := min(i + k, n - 1)
			for ; i < j && str1[j] == '.'; j-- {}
			if i == j {
				break
			}
			result++
			i = j
		}
		fmt.Println(result)
	}
}

func getFirstStarIndex(str string) int {
	for i, char := range str {
		if char == '*' {
			return  i
		}
	}
	return 0
}

func min(arg1 int, rest ...int) int {
	curr := arg1
	for _, num := range rest {
		if num < curr {
			curr = num
		}
	}
	return curr
}

package main

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

func main() {

	input := bufio.NewReader(os.Stdin)
	var testCases int
	fmt.Fscan(input, &testCases)

	for testCases > 0 {
		testCases--
		var str1 string
		var n, k int
		result := 1
		fmt.Fscan(input, &n, &k, &str1)
		i := getFirstStarIndex(str1)
		println(i)
		for 0 < 1 {
			j := min(i + k, n - 1)
			for ; i < j && str1[j] == '.'; j-- {}
			if i == j {
				break
			}
			result++
			i = j
		}
		fmt.Println(result)
	}
}

func getFirstStarIndex(str string) int {
	for i, char := range str {
		if char == '*' {
			return  i
		}
	}
	return 0
}

func min(arg1 int, rest ...int) int {
	curr := arg1
	for _, num := range rest {
		if num < curr {
			curr = num
		}
	}
	return curr
}

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func solve() {
	n, k := getI(), getI()
	s := []rune(getS())

	first := int64(-1)
	last := int64(-1)

	for i := int64(0); i < n; i++ {
		if s[i] == '*' {
			if first == -1 {
				first = i
			}
			last = i
		}
	}

	if first == last {
		out(1)
		return
	}

	cur := first
	count := 2
	for i := first + k; i < last-k; i += k {
		if s[i] == '*' {
			cur = i
			s[i] = 'x'
			count++
		} else {
			i--
			for s[i] != '*' {
				i--
			}
			cur = i
			s[i] = 'x'
			count++
		}
	}

	for i := last - k; i > cur; i -= k {
		if s[i] == '*' {
			s[i] = 'x'
			count++
		} else {
			i++
			for s[i] != '*' {
				i++
			}
			s[i] = 'x'
			count++
		}
	}

	out(count)
}

// http://github.com/KadoBOT (me@ricardoambrogi.com)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	for i := getI(); i > 0; i-- {
		solve()
	}
	out()
}

// !------- HELPERS -------!
func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func ceil(n, d int64) int64 {
	return (n + d - 1) / d
}

func nsort(data ...int64) []int64 {
	sort.SliceStable(data, func(i, j int) bool { return data[i] < data[j] })
	return data
}

func nsorti(data ...int64) []int64 {
	idxs := make([]int64, len(data))
	for i := 0; i < len(data); i++ {
		idxs[i] = int64(i)
	}

	sort.SliceStable(idxs, func(i, j int) bool { return data[idxs[i]] < data[idxs[j]] })
	return idxs
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(s ...int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

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

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

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

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// !------- FORMULAS -------!
func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func lcm(a, b int64, integers ...int64) int64 {
	result := a * b / gcd(a, b)

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

	return result
}

func sieve(n int64) []int64 {
	integers := make([]bool, n+1)
	for i := int64(2); i < n+1; i++ {
		integers[i] = true
	}

	for p := int64(2); p*p <= n; p++ {
		if integers[p] == true {
			for i := p * 2; i <= n; i += p {
				integers[i] = false
			}
		}
	}

	var primes []int64
	for p := int64(2); p <= n; p++ {
		if integers[p] == true {
			primes = append(primes, p)
		}
	}

	return primes
}

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, k int
		fmt.Fscan(in, &n, &k)

		var s string
		fmt.Fscan(in, &s)

		arr := []int{}
		for i, ch := range s {
			if ch == '*' {
				arr = append(arr, i)
			}
		}

		tally := 1
		for i := 0; i < len(arr)-1; {
			var pos int
			for j := i + 1; j < len(arr); j++ {
				if arr[j]-arr[i] > k {
					break
				}
				pos = j
			}

			tally++
			i = pos
		}
		fmt.Fprintln(out, tally)
	}
}

package main

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

func readLine(in *bufio.Reader) string {
    ret, _, err := in.ReadLine()

    if err == io.EOF {
        return ""
    }

    return strings.TrimRight(string(ret), "\r\n")
}

func parseInt(in string) int {
    ret, _ := strconv.ParseInt(in, 10, 64)
    return int(ret)
}

func split(in string) []string {
    return strings.Split(in, " ")
}

func main() {
    in := bufio.NewReaderSize(os.Stdin, 1024*1024)
    out := bufio.NewWriter(os.Stdout)

    defer out.Flush()

    for t := parseInt(readLine(in)); t > 0; t-- {
        run(in, out)
    }
}

func run(in io.Reader, out io.Writer) {
    /* ----------------------------------------------------
     * NOTE: Solution 1506B
     *
     * @author      : Hung Nguyen Xuan Pham (hung0913208@gmail.com)
     * @created     : Sunday Nov 28, 2021 17:27:06 +07
     * @filename    : 1506B
     * ----------------------------------------------------- */
    var n, k, cnt int
    var s string

    fmt.Fscan(in, &n, &k, &s)

    i := strings.Index(s, "*")
    if i >= 0 {
        cnt = 1
    } else {
        cnt = 0
    }

    for i >= 0 {
        var j int

        for j = min(n - 1, i + k); j > i; j-- {
            if s[j] != '.' {
                break
            }
        }

        if i == j {
            break
        }

        cnt++
        i = j
    }

    fmt.Fprintln(out, cnt)
}

func min(l, r int) int {
    if l < r {
        return l
    } else {
        return r
    }
}

package main

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

const N int = 2000

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

	var T int
	for Fscan(in, &T); T > 0; T-- {
		var k, n int
		var s []byte
		Fscan(in, &n, &k, &s)
		// Fix first one
		firstPos := -1
		for i := 0; i < n; i++ {
			if s[i] == '*' {
				firstPos = i
				s[i] = 'x'
				break
			}
		}
		if firstPos == -1 {
			Fprint(out, 0)
			continue
		}

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

		// span from firstPos out
		pos := firstPos
		count := 1
		for {
			// Fprintf(out, "%s pos = %d\n", s, pos)
			changed := false
			for i := min(pos+k, n-1); i > pos; i-- {
				// Fprintf(out, "i = %d, s[i] = %c\n", i, s[i])
				if s[i] == '*' {
					s[i] = 'x'
					changed = true
					pos = i
					count++
					break
				}
			}
			if !changed {
				break
			}
		}
		Fprintln(out, count)
	}

}

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

package main

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

type Scanner struct {
	bScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bScanner := bufio.NewScanner(os.Stdin)
	bScanner.Split(bufio.ScanWords)
	bScanner.Buffer([]byte{}, math.MaxInt32)
	return &Scanner{
		bScanner,
	}
}

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

func (s *Scanner) nextInt() int {
	s.bScanner.Scan()
	res, err := strconv.Atoi(s.bScanner.Text())
	if err != nil {
		panic(err)
	}
	return res
}

func (s *Scanner) nextInt64() int64 {
	s.bScanner.Scan()
	res, err := strconv.ParseInt(s.bScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (s *Scanner) nextFloat() float64 {
	s.bScanner.Scan()
	res, err := strconv.ParseFloat(s.bScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (s *Scanner) nextInts(N int) []int {
	res := make([]int, N)
	for i := 0; i < N; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextInt64s(N int) []int64 {
	res := make([]int64, N)
	for i := 0; i < N; i++ {
		res[i] = s.nextInt64()
	}
	return res
}

func min(nums ...int) int {
	ans := math.MaxInt32
	for _, num := range nums {
		if num < ans {
			ans = num
		}
	}
	return ans
}

func max(nums ...int) int {
	ans := math.MinInt32
	for _, num := range nums {
		if num > ans {
			ans = num
		}
	}
	return ans
}

func main() {
	sc := NewScanner()
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	TC := sc.nextInt()
	for tc := 0; tc < TC; tc++ {
		N := sc.nextInt()
		K := sc.nextInt()
		str := sc.next()

		replacePos := make([]int, 0)
		for i := 0; i < N; i++ {
			if str[i] == '*' {
				if len(replacePos) < 2 {
					replacePos = append(replacePos, i)
				} else {
					if i-replacePos[len(replacePos)-2] <= K {
						replacePos[len(replacePos)-1] = i
					} else {
						replacePos = append(replacePos, i)
					}
				}
			}
		}
		fmt.Fprintln(wr, len(replacePos))
	}
}

package main
import "fmt"

func solve(s* string, k int) int {
	idx := make([]int, 0, len(*s))
	for i, el := range(*s) {
		if (el == '*') {
			idx = append(idx, i)
		}
	}

	var i,j,res int = 0,0,1
	for i != len(idx) - 1 {
		for (j < len(idx) && idx[j] - idx[i] <= k) {
			j++
		}
		res++
		i = j - 1
	}
	return res
}

func main() {
	var t,n,k int
	var s string
	fmt.Scan(&t)
	for i := 1; i <= t; i++ {
		fmt.Scan(&n,&k)
		fmt.Scan(&s)
		fmt.Println(solve(&s, k))
	}
}

// Package main provides ...
package main

import (
	"fmt"
	"strings"
)

func main() {
	var t int
	fmt.Scan(&t)
	for j := 0; j < t; j++ {
		var st string
		var n, k int
		fmt.Scan(&n, &k)
		fmt.Scan(&st)
		st = strings.Trim(st, ".")
		if len(st) == 1 {
			fmt.Println(1)
			continue
		}
		i := 0
		rs := 0
		for ; i < len(st); i += k {
			for ; st[i] != '*'; i-- {
			}
			rs++
		}
		if i < len(st)+k-1 {
			rs++
		}
		fmt.Println(rs)
	}
}

package main

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

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

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

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

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

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

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

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

		}
		return initial
	}
}

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

}

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

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

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

		var n, k int

		fmt.Fscan(input, &n)
		fmt.Fscan(input, &k)
		STRING := make([]byte, 0)
		fmt.Fscan(input, &STRING)
		NNN := make([]int, 0)
		for i := 0; i < n; i++ {
			if string(STRING[i]) == "*" {
				NNN = append(NNN, i+1)
			}
		}

		answer := 1
		l := len(NNN)
		begin := NNN[0]
		for i := 1; i < l; i++ {
			if NNN[i]-begin > k {
				answer++
				begin = NNN[i-1]

			}
		}

		if begin != NNN[l-1] {
			answer++
		}
		fmt.Println(answer)

	}

}

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.Fscanf(in, "%d\n", &T)
	for t := 0; t < T; t++ {
		var n int
		var k int
		var s string

		fmt.Fscanf(in, "%d %d\n", &n, &k)
		fmt.Fscanf(in, "%s\n", &s)

		ans := 0

		i := 0
		for i < len(s) {
			if s[i] == '.' {
				i++
				continue
			}
			ans++
			t := k
			for i+t >= len(s) {
				t--
			}
			for t > 0 && i+t < len(s) && s[i+t] != '*' {
				t--
			}
			if t == 0 {
				break
			}
			i += t
		}

		fmt.Fprintf(out, "%v\n", ans)
	}
}

package main

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

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

	solve := func(Case int) {
		var n, k int
		var s []byte
		Fscan(in, &n, &k, &s)
		t := append([]byte(nil), s...)
		i, j := bytes.IndexByte(s, '*'), bytes.LastIndexByte(s, '*')
		t[i] = 'x'
		t[j] = 'x'
		pre := i
		for {
			nxt := pre + k
			if nxt >= j {
				break
			}
			if nxt == '*' {
				t[nxt] = 'x'
				pre = nxt
			} else {
				for ; t[nxt] != '*'; nxt-- {
				}
				t[nxt] = 'x'
				pre = nxt
			}
		}
		ans := 0
		for i, b := range s {
			if b != t[i] {
				ans++
			}
		}
		Fprintln(out, ans)
	}

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

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

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

package main

import (
	"bufio"
	"fmt"
	"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 min_int(a int, b int) int { if a < b { return a } else { return b } }
func min_int64(a int64, b int64) int64 { if a < b { return a } else { return b } }

func max_int(a int, b int) int { if a > b { return a } else { return b } }
func max_int64(a int64, b int64) int64 { if a > b { return a } else { return b } }

func main() {
	defer writer.Flush()

	var T int = 0
	scanf("%d\n", &T)

	for t := 0; t < T; t++ {

		var n int = 0
		var k int = 0
		scanf("%d %d\n", &n, &k)
		var s string
		scanf("%s\n", &s)

		res := make([]int, n)
		var index int = 0
		for i := 0; i < n; i++ {
			if s[i] == '*' {
				res[i] = 1
				index = i
				// printf("index: %d\n", index)
				break
			}
		}

		for i := index; i < n; i++ {
			// printf("I: %d\n", i)

			var max_index = -1

			for j := i; j <= min_int(n-1, i+k); j++ {
				if s[j] == '*' {
					// printf("j: %d\n", j)
					max_index = j
				}
			}

			// printf("max_index: %d\n", max_index)
			if max_index != -1 {
				res[max_index] = 1
			}
			i = i + k - 1
		}

		for i := n-1; i >= 0; i-- {
			if s[i] == '*' && res[i] == 1 {
				break
			}

			if s[i] == '*' {
				res[i] = 1
				index = i
				break
			}
		}

		var ans int = 0
		for i := 0; i < n; i++ {
			if res[i] == 1 {
				ans = ans + 1
			}
			// printf("%d ", res[i])
		}
		// printf("\n")
		printf("%d\n", 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 min_int(a int, b int) int { if a < b { return a } else { return b } }
func min_int64(a int64, b int64) int64 { if a < b { return a } else { return b } }

func max_int(a int, b int) int { if a > b { return a } else { return b } }
func max_int64(a int64, b int64) int64 { if a > b { return a } else { return b } }

func main() {
	defer writer.Flush()

	var T int = 0
	scanf("%d\n", &T)

	for t := 0; t < T; t++ {

		var n int = 0
		var k int = 0
		scanf("%d %d\n", &n, &k)
		var s string
		scanf("%s\n", &s)

		res := make([]int, n)
		var index int = 0
		for i := 0; i < n; i++ {
			if s[i] == '*' {
				res[i] = 1
				index = i
				// printf("index: %d\n", index)
				break
			}
		}

		for i := index; i < n; i++ {
			// printf("I: %d\n", i)

			var max_index = i

			for j := i; j <= min_int(n-1, i+k); j++ {
				if s[j] == '*' {
					max_index = j
				}
			}

			// printf("max_index: %d\n", max_index)
			res[max_index] = 1
			i = i + k - 1
		}

		for i := n-1; i >= 0; i-- {
			if s[i] == '*' && res[i] == 1 {
				break
			}

			if s[i] == '*' {
				res[i] = 1
				index = i
				break
			}
		}

		var ans int = 0
		for i := 0; i < n; i++ {
			if res[i] == 1 {
				ans = ans + 1
			}
			// printf("%d ", res[i])
		}
		// printf("\n")
		printf("%d\n", 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 min_int(a int, b int) int { if a < b { return a } else { return b } }
func min_int64(a int64, b int64) int64 { if a < b { return a } else { return b } }

func max_int(a int, b int) int { if a > b { return a } else { return b } }
func max_int64(a int64, b int64) int64 { if a > b { return a } else { return b } }

func main() {
	defer writer.Flush()

	var T int = 0
	scanf("%d\n", &T)

	for t := 0; t < T; t++ {

		var n int = 0
		var k int = 0
		scanf("%d %d\n", &n, &k)
		var s string
		scanf("%s\n", &s)

		res := make([]int, n)
		var index int = 0
		for i := 0; i < n; i++ {
			if s[i] == '*' {
				res[i] = 1
				index = i
				// printf("index: %d\n", index)
				break
			}
		}

		for i := index; i < n; i++ {
			// printf("I: %d\n", i)
			for j := min_int(n - 1, i + k); j >= i; j-- {
				if s[j] == '*' {
					// printf("-> j: %d\n", j)
					res[j] = 1
					i = i + k - 1
					break
				}
			}
		}

		for i := n-1; i >= 0; i-- {
			if s[i] == '*' && res[i] == 1 {
				break
			}

			if s[i] == '*' {
				res[i] = 1
				index = i
				break
			}
		}

		var ans int = 0
		for i := 0; i < n; i++ {
			if res[i] == 1 {
				ans = ans + 1
			}
			// printf("%d ", res[i])
		}
		// printf("\n")
		printf("%d\n", 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 min_int(a int, b int) int { if a < b { return a } else { return b } }
func min_int64(a int64, b int64) int64 { if a < b { return a } else { return b } }

func max_int(a int, b int) int { if a > b { return a } else { return b } }
func max_int64(a int64, b int64) int64 { if a > b { return a } else { return b } }

func main() {
	defer writer.Flush()

	var T int = 0
	scanf("%d\n", &T)

	for t := 0; t < T; t++ {

		var n int = 0
		var k int = 0
		scanf("%d %d\n", &n, &k)
		var s string
		scanf("%s\n", &s)

		res := make([]int, n)
		var index int = 0
		for i := 0; i < n; i++ {
			if s[i] == '*' {
				res[i] = 1
				index = i
				// printf("index: %d\n", index)
				break
			}
		}

		for i := index; i < n; i++ {
			// printf("I: %d\n", i)
			for j := min_int(n - 1, i + k); j > i; j-- {
				if s[j] == '*' {
					// printf("-> j: %d\n", j)
					res[j] = 1
					i = i + k - 1
					break
				}
			}
		}

		for i := n-1; i >= 0; i-- {
			if s[i] == '*' && res[i] == 1 {
				break
			}

			if s[i] == '*' {
				res[i] = 1
				index = i
				break
			}
		}

		var ans int = 0
		for i := 0; i < n; i++ {
			if res[i] == 1 {
				ans = ans + 1
			}
			// printf("%d ", res[i])
		}
		// printf("\n")
		printf("%d\n", 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 min_int(a int, b int) int { if a < b { return a } else { return b } }
func min_int64(a int64, b int64) int64 { if a < b { return a } else { return b } }

func max_int(a int, b int) int { if a > b { return a } else { return b } }
func max_int64(a int64, b int64) int64 { if a > b { return a } else { return b } }

func main() {
	defer writer.Flush()

	var T int = 0
	scanf("%d\n", &T)

	for t := 0; t < T; t++ {

		var n int = 0
		var k int = 0
		scanf("%d %d\n", &n, &k)
		var s string
		scanf("%s\n", &s)

		res := make([]int, n)
		var index int = 0
		for i := 0; i < n; i++ {
			if s[i] == '*' {
				res[i] = 1
				index = i
				break
			}
		}

		for i := index; i < n; i++ {
			for j := min_int(n - 1, i + k); j > i; j-- {
				if s[j] == '*' {
					res[j] = 1
					i = i + k + 1
					break
				}

			}
		}

		for i := n-1; i >= 0; i-- {
			if s[i] == '*' && res[i] == 1 {
				break
			}

			if s[i] == '*' {
				res[i] = 1
				index = i
				break
			}
		}

		var ans int = 0
		for i := 0; i < n; i++ {
			if res[i] == 1 {
				ans = ans + 1
			}

			// printf("%d ", res[i])
		}
		printf("%d\n", ans)

	}

}

package main

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

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

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n, k int
		var s []byte
		Fscan(in, &n, &k, &s)

		ans := 1
		start := bytes.Index(s, []byte{'*'})
		end := bytes.LastIndex(s, []byte{'*'})
		if start != end {
			ans = 2
		}
		ans += max(0, (end - start - 1) / k)
		Fprintln(out, ans)

	}
}

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

func decomposition(n int) []int {
	var res []int
	for p := 2; n >= p * p;  {
		if n % p == 0 {
			res = append(res, p)
			n /= p
		} else {
			p++
		}
	}
	if n > 1 {
		res = append(res, n)
	}
	return res
}

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

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func solve() {
	n, m, x := getI(), getI(), getI()
	var row int64
	var col int64

	row = x % n
	col = ceil(x, n)

	if row == 0 {
		row = n
	}

	out(row*m - m + col)
}

// http://github.com/KadoBOT (me@ricardoambrogi.com)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	for i := getI(); i > 0; i-- {
		solve()
	}
	out()
}

// !------- HELPERS -------!
func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func ceil(n, d int64) int64 {
	return (n + d - 1) / d
}

func nsort(data ...int64) []int64 {
	sort.SliceStable(data, func(i, j int) bool { return data[i] < data[j] })
	return data
}

func nsorti(data ...int64) []int64 {
	idxs := make([]int64, len(data))
	for i := 0; i < len(data); i++ {
		idxs[i] = int64(i)
	}

	sort.SliceStable(idxs, func(i, j int) bool { return data[idxs[i]] < data[idxs[j]] })
	return idxs
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(s ...int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

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

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

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

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// !------- FORMULAS -------!
func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func lcm(a, b int64, integers ...int64) int64 {
	result := a * b / gcd(a, b)

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

	return result
}

func sieve(n int64) []int64 {
	integers := make([]bool, n+1)
	for i := int64(2); i < n+1; i++ {
		integers[i] = true
	}

	for p := int64(2); p*p <= n; p++ {
		if integers[p] == true {
			for i := p * 2; i <= n; i += p {
				integers[i] = false
			}
		}
	}

	var primes []int64
	for p := int64(2); p <= n; p++ {
		if integers[p] == true {
			primes = append(primes, p)
		}
	}

	return primes
}


// Author: sighduck
// URL: https://codeforces.com/contest/1163/problem/C2

package main

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

type Point struct {
	X int64
	Y int64
}

type Line struct {
	A int64
	B int64
}

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

func createLine(p1 Point, p2 Point) Line {
	A := p1.Y - p2.Y
	B := p1.X - p2.X
	d := gcd(A, B)
	return Line{
		A: A / d,
		B: B / d,
	}
}

func Solve(n int, poles []Point) int64 {
	lineMap := make(map[Line]map[int64]int)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			pi, pj := poles[i], poles[j]
			line := createLine(pi, pj)
			_, ok := lineMap[line]
			if !ok {
				lineMap[line] = make(map[int64]int)
			}
			lineMap[line][line.A*pi.X-line.B*pi.Y] += 1
		}
	}
	total := int64(0)
	parallel := int64(0)
	for _, nestedMap := range lineMap {
		count := int64(len(nestedMap))
		total += count
		parallel += count * (count - 1) / 2
	}
	return total*(total-1)/2 - parallel
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	poles := make([]Point, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d %d\n", &poles[i].X, &poles[i].Y)
	}

	fmt.Fprintf(writer, "%d\n", Solve(n, poles))
}

package main

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

func sign(x int) int {
    switch {
    case x < 0:
        return -1
    case x == 0:
        return 0
    default:
        return 1
    }
}

func abs(x int) int {
    if x >= 0 {
        return x
    } else {
        return -x
    }
}

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

type fraction struct {
    a, b int
}

func (f *fraction) standardize() {
    if f.a == 0 {
        f.b = 1
        return
    }
    if f.b == 0 {
        f.a = 1
        return
    }

    g := gcd(abs(f.a), abs(f.b))
    f.a /= g
    f.b /= g
    if f.b < 0 {
        f.a, f.b = -f.a, -f.b
    }
}

func compareFractions(f1 *fraction, f2 *fraction) int {
    f1.standardize()
    f2.standardize()

    switch {
    case f1.b == 0 && f2.b == 0:
        return 0
    case f1.b == 0:
        return 1
    case f2.b == 0:
        return -1
    default:
        return f1.a * f2.b - f1.b * f2.a
    }
}

type point struct {
    x, y int
}

type vector struct {
    x, y int
}

func newVector(start *point, end *point) vector {
    return vector { end.x - start.x, end.y - start.y }
}

func isParallel(v1 *vector, v2 *vector) bool {
    return v1.x * v2.y == v2.x * v1.y
}

type line struct {
    p point
    v vector
}

func newLine(p1 *point, p2 *point) line {
    return line { p: *p1, v: newVector(p1, p2) }
}

func (l *line) slope() fraction {
    s := fraction { l.v.y, l.v.x }
    (&s).standardize()
    return s
}

var n int
var p []point
var l []line

func read() {
    input := bufio.NewScanner(os.Stdin)
    input.Split(bufio.ScanWords)

    input.Scan()
    n, _ = strconv.Atoi(input.Text())

    p = make([]point, n, n)
    for i := range p {
        input.Scan()
        p[i].x, _ = strconv.Atoi(input.Text())

        input.Scan()
        p[i].y, _ = strconv.Atoi(input.Text())
    }
}

func extractLines() {
    pp := make([]point, n, n)
    copy(pp, p)

    l = make([]line, 0)
    for _, pt := range p {
        sort.Slice(pp, func (i, j int) bool {
            if pp[i] == pt {
                return false
            }
            if (pp[j] == pt) {
                return true
            }

            fi := fraction { pp[i].y - pt.y, pp[i].x - pt.x }
            fj := fraction { pp[j].y - pt.y, pp[j].x - pt.x }
            return compareFractions(&fi, &fj) < 0
        })

        i := 0
        for i < len(pp) {
            if pp[i] == pt {
                break
            }

            j := i
            for j < len(pp) {
                fi := fraction { pp[i].y - pt.y, pp[i].x - pt.x }
                fj := fraction { pp[j].y - pt.y, pp[j].x - pt.x }
                if compareFractions(&fi, &fj) == 0 {
                    j++
                } else {
                    break
                }
            }

            ok := true
            for k := i; k < j; k++ {
                if pp[k].x < pt.x {
                    ok = false
                    break
                }
                if (pp[k].x == pt.x && pp[k].y > pt.y) {
                    ok = false
                    break
                }
            }

            if ok {
                l = append(l, newLine(&pt, &pp[i]))
            }

            i = j
        }
    }
}

func main() {
    read()
    extractLines()

    slopecnt := make(map[fraction]int)
    for _, ln := range l {
        slopecnt[(&ln).slope()]++
    }

    ans := int64(0)
    for _, c := range slopecnt {
        ans += int64(c) * int64(len(l) - c)
    }
    ans /= 2

    fmt.Println(ans)
}

package main

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

func GCD(a, b int) int {
    switch {
    case b != 0:
        return GCD(b, a % b)
    default:
        return a
    }
}

type Fraction struct {
    a, b int
}

func (f *Fraction) standardize() {
    if f.b == 0 {
        f.a = 1
        return
    } else if f.a == 0 {
        f.b = 1
        return
    }

    g := GCD(f.a, f.b)
    f.a /= g
    f.b /= g
}

type Point struct {
    x, y int
}

type Vector struct {
    x, y int
}

func NewVector(start *Point, end *Point) Vector {
    return Vector {
        x: end.x - start.x,
        y: end.y - start.y }
}

func (v *Vector) Reverse() {
    v.x, v.y = -v.x, -v.y
}

func IsParallel(v1 *Vector, v2 *Vector) bool {
    return v1.x * v2.y == v2.x * v1.y
}

type Line struct {
    p Point
    v Vector
}

func NewLine(p1 *Point, p2 *Point) Line {
    l := Line {
        p: *p1,
        v: NewVector(p1, p2) }
    if l.v.x < 0 {
        (&l.v).Reverse()
    }
    return l
}

func (l *Line) Slope() Fraction {
    f := Fraction { l.v.y, l.v.x }
    (&f).standardize()
    return f
}

func IsSameLine(l1 *Line, l2 *Line) bool {
    v := NewVector(&l1.p, &l2.p)
    return IsParallel(&l1.v, &l2.v) && IsParallel(&l1.v, &v)
}

var n int
var p []Point
var lines []Line

func read() {
    input := bufio.NewScanner(os.Stdin)
    input.Split(bufio.ScanWords)

    input.Scan()
    n, _ = strconv.Atoi(input.Text())

    p = make([]Point, n, n)
    for i := range p {
        input.Scan()
        p[i].x, _ = strconv.Atoi(input.Text())

        input.Scan()
        p[i].y, _ = strconv.Atoi(input.Text())
    }
}

func uniqueLines() {
    i := 1
    for j := 1; j < len(lines); j++ {
        if (!IsSameLine(&lines[i - 1], &lines[j])) {
            lines[i], lines[j] = lines[j], lines[i]
            i++
        }
    }
    lines = lines[:i]
}

func main() {
    read()

    lines = make([]Line, 0, n * (n - 1) / 2)
    for i := range p {
        for j := i + 1; j < n; j++ {
            lines = append(lines, NewLine(&p[i], &p[j]))
        }
    }
    sort.Slice(lines, func (i, j int) bool {
        return lines[i].v.y < lines[j].v.y
    })
    uniqueLines()

    slopecnt := make(map[Fraction]int)
    for _, l := range lines {
        slopecnt[(&l).Slope()]++
    }

    var ans int64 = 0
    for _, cnt := range slopecnt {
        ans += int64(cnt) * int64(len(lines) - cnt)
    }
    ans /= 2

    fmt.Println(ans)
}

// Author: sighduck
// URL: https://codeforces.com/contest/1163/problem/C2

package main

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

type Point struct {
	X int
	Y int
}

type Line struct {
	IsVertical bool
	M          float64
	B          float64
	P1         Point
	P2         Point
}

func createLine(p1 Point, p2 Point) Line {
	dy := p2.Y - p1.Y
	dx := p2.X - p1.X
	m := float64(dy) / float64(dx)
	b := float64(p1.Y) - m*float64(p1.X)
	return Line{
		IsVertical: dx == 0,
		P1:         p1,
		P2:         p2,
		M:          m,
		B:          b,
	}
}

func Solve(n int, poles []Point) int64 {
	lineMap := make(map[float64]map[float64]int)
	verticalMap := make(map[int]int)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			pi, pj := poles[i], poles[j]
			line := createLine(pi, pj)
			if line.IsVertical {
				verticalMap[line.P1.X] += 1
			} else {
				_, ok := lineMap[line.M]
				if !ok {
					lineMap[line.M] = make(map[float64]int)
				}
				lineMap[line.M][line.B] += 1
			}
		}
	}
	totalLines := len(verticalMap)
	parallelPairs := 0
	for _, nestedMap := range lineMap {
		totalLines += len(nestedMap)
		parallelPairs += len(nestedMap) * (len(nestedMap) - 1) / 2
	}
	parallelPairs += len(verticalMap) * (len(verticalMap) - 1) / 2
	return int64(totalLines)*int64(totalLines-1)/int64(2) - int64(parallelPairs)
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	poles := make([]Point, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d %d\n", &poles[i].X, &poles[i].Y)
	}

	fmt.Fprintf(writer, "%d\n", Solve(n, poles))
}


package main

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

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

func main() {
	var n, m int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n, &m)
	arr := make([]int, n)
	rem := make([]int, 2)
	flag := make(map[int]bool)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])
		if !flag[arr[i]] {
			rem[arr[i]%2]++
		}
		flag[arr[i]] = true
	}

	ans := make([]int, n)
	left0, left1 := n/2-rem[0], n/2-rem[1]
	cangrab0 := make([]int, 0)
	cangrab1 := make([]int, 0)
	if left0 > 0 {
		i := 2
		for i <= m && left0 > 0 {
			if !flag[i] {
				cangrab0 = append(cangrab0, i)
				left0--
			}
			i += 2
		}
	}

	if left1 > 0 {
		i := 1
		for i <= m && left1 > 0 {
			if !flag[i] {
				cangrab1 = append(cangrab1, i)
				left1--
			}
			i += 2
		}
	}
	if left0 > 0 || left1 > 0 {
		fmt.Println(-1)
	} else {
		a0, a1 := n/2, n/2
		for index, key := range arr {
			if !flag[key] {
				continue
			}
			flag[key] = false
			mod := key % 2
			if mod == 0 {
				if a0 > 0 {
					ans[index] = key
					a0--
				}
			} else {
				if a1 > 0 {
					ans[index] = key
					a1--
				}
			}
		}
		index := 0
		i0, i1, cnt := 0, 0, 0
		for a0 > 0 {
			for ans[index] != 0 {
				index++
			}
			ans[index] = cangrab0[i0]
			index++
			cnt++
			i0++
			a0--
		}
		for a1 > 0 {
			for ans[index] != 0 {
				index++
			}
			ans[index] = cangrab1[i1]
			index++
			cnt++
			i1++
			a1--
		}
		fmt.Println(cnt)
		for i := 0; i < n; i++ {
			fmt.Print(ans[i], " ")
		}
		fmt.Println()
	}

}

package main

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

type Val struct {
    v, i int
}

type ByV []Val
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, m := readInt(), readInt()
    was := make(map[int]bool)
    a := make([]Val, n)
    for i := 0; i < n; i++ {
        a[i] = Val{v:readInt(), i:i}
    }
    sort.Sort(sort.Reverse(ByV(a)))
    odd, even := 0, 0
    for i, val := range a {
        v := val.v
        skip := false
        if was[v] {
            skip = true
        } else {
            was[v] = true
            if v%2 == 0 {
                even++
                if even > n/2 {
                    skip = true
                }
            } else {
                odd++
                if odd > n/2 {
                    skip = true
                }
            }
        }
        if skip {
            a[i].v = 0
        }
    }
    ans, ok := 0, true
    moveNext := func(curM *int) {
        for was[*curM] {
            *curM += 2
        }
        was[*curM] = true
        ans++
        ok = ok && *curM <= m
    }

    oddM, evenM := 1, 2
    index := make(map[int]int)
    for i, val := range a {
        index[val.i] = i
        if val.v > 0 {
            continue
        }
        if even < n/2 {
            moveNext(&evenM)
            a[i].v = evenM
            even++
        } else if odd < n/2 {
            moveNext(&oddM)
            a[i].v = oddM
            odd++
        }
    }
    if !ok {
        ans = -1
    }
    fmt.Println(ans)
    if ok {
        for i := 0; i < n; i++ {
            fmt.Print(a[index[i]].v, " ")
        }
        fmt.Println()
    }
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

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

/* Sort template
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

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

type Val struct {
    v, i int
}

type ByV []Val
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, m := readInt(), readInt()
    was := make(map[int]bool)
    a := make([]Val, n)
    for i := 0; i < n; i++ {
        a[i] = Val{v:readInt(), i:i}
    }
    sort.Sort(sort.Reverse(ByV(a)))
    odd, even := 0, 0
    for i, val := range a {
        v := val.v
        skip := false
        if was[v] {
            skip = true
        } else {
            was[v] = true
            if v%2 == 0 {
                even++
                if even > n/2 {
                    skip = false
                }
            } else {
                odd++
                if odd > n/2 {
                    skip = false
                }
            }
        }
        if skip {
            a[i].v = 0
        }
    }
    ans, ok := 0, true
    moveNext := func(curM *int) {
        for was[*curM] {
            *curM += 2
        }
        was[*curM] = true
        ans++
        ok = ok && *curM <= m
    }

    oddM, evenM := 1, 2
    index := make(map[int]int)
    for i, val := range a {
        index[val.i] = i
        if val.v > 0 {
            continue
        }
        if even < n/2 {
            moveNext(&evenM)
            a[i].v = evenM
            even++
        } else if odd < n/2 {
            moveNext(&oddM)
            a[i].v = oddM
            odd++
        }
    }
    if !ok {
        ans = -1
    }
    fmt.Println(ans)
    if ok {
        for i := 0; i < n; i++ {
            fmt.Print(a[index[i]].v, " ")
        }
        fmt.Println()
    }
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

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

/* Sort template
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

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

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

func main() {
	var n, m int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n, &m)
	arr := make([]int, n)
	rem := make([]int, 2)
	flag := make(map[int]bool)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])
		if !flag[arr[i]] {
			rem[arr[i]%2]++
		}
		flag[arr[i]] = true
	}

	ans := make([]int, 0)
	left0, left1 := n/2-rem[0], n/2-rem[1]
	cangrab0 := make([]int, 0)
	cangrab1 := make([]int, 0)
	if left0 > 0 {
		i := 2
		for i <= m && left0 > 0 {
			if !flag[i] {
				cangrab0 = append(cangrab0, i)
				left0--
			}
			i += 2
		}
	}

	if left1 > 0 {
		i := 1
		for i <= m && left1 > 0 {
			if !flag[i] {
				cangrab1 = append(cangrab1, i)
				left1--
			}
			i += 2
		}
	}
	if left0 > 0 || left1 > 0 {
		fmt.Println(-1)
	} else {
		a0, a1 := n/2, n/2
		for key, _ := range flag {
			mod := key % 2
			if mod == 0 {
				if a0 > 0 {
					ans = append(ans, key)
					a0--
				}
			} else {
				if a1 > 0 {
					ans = append(ans, key)
					a1--
				}
			}
		}
		i0, i1, cnt := 0, 0, 0
		for a0 > 0 {
			ans = append(ans, cangrab0[i0])
			cnt++
			i0++
			a0--
		}
		for a1 > 0 {
			ans = append(ans, cangrab1[i1])
			cnt++
			i1++
			a1--
		}
		fmt.Println(cnt)
		for i := 0; i < n; i++ {
			fmt.Print(ans[i], " ")
		}
		fmt.Println()
	}

}