You are given $$$n$$$ points with integer coordinates on a coordinate axis $$$OX$$$. The coordinate of the $$$i$$$-th point is $$$x_i$$$. All points' coordinates are distinct and given in strictly increasing order.For each point $$$i$$$, you can do the following operation no more than once: take this point and move it by $$$1$$$ to the left or to the right (i..e., you can change its coordinate $$$x_i$$$ to $$$x_i - 1$$$ or to $$$x_i + 1$$$). In other words, for each point, you choose (separately) its new coordinate. For the $$$i$$$-th point, it can be either $$$x_i - 1$$$, $$$x_i$$$ or $$$x_i + 1$$$.Your task is to determine if you can move some points as described above in such a way that the new set of points forms a consecutive segment of integers, i. e. for some integer $$$l$$$ the coordinates of points should be equal to $$$l, l + 1, \ldots, l + n - 1$$$.Note that the resulting points should have distinct coordinates.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of points in the set $$$x$$$. The second line of the test case contains $$$n$$$ integers $$$x_1 < x_2 < \ldots < x_n$$$ ($$$1 \le x_i \le 10^6$$$), where $$$x_i$$$ is the coordinate of the $$$i$$$-th point. It is guaranteed that the points are given in strictly increasing order (this also means that all coordinates are distinct). It is also guaranteed that the sum of $$$n$$$ does not exceed $$$2 \cdot 10^5$$$ ($$$\sum n \le 2 \cdot 10^5$$$).

// 00
package main

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

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		ok := true
		two_count := 0
		three_count := 0

		for i := 1; i < n; i++ {
			diff := a[i] - a[i-1]
			if diff > 3 {
				ok = false
				break
			} else if diff > 1 {
				if diff == 2 {
					two_count++
				} else {
					three_count++
				}
				if two_count > 2 || three_count > 1 || (three_count >= 1 && two_count >= 1) {
					ok = false
					break
				}

			}
		}
		if ok {
			write(f, "YES\n")
		} else {
			write(f, "NO\n")
		}
	}
}

package main

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

const maxTokenSize = 2500000 * 7

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Buffer(make([]byte, 0, maxTokenSize), maxTokenSize)
    scanner.Scan()

    count, _ := strconv.Atoi(scanner.Text())

out:
    for i := 0; i < count; i++ {
        scanner.Scan()
        dotsCount, _ := strconv.Atoi(scanner.Text())

        var dots []int
        scanner.Scan()
        for _, dot := range strings.Split(scanner.Text(), " ") {
            d, _ := strconv.Atoi(dot)
            dots = append(dots, d)
        }

        if dotsCount == 1 {
            fmt.Println("YES")
            continue
        }

        var diff int
        for i := range dots {
            if len(dots)-1 == i {
				break
            }

            diff += dots[i+1] - dots[i] - 1
        }

        if diff <= 2 {
            fmt.Println("YES")
            continue out
        }

        fmt.Println("NO")
    }
}

package main

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

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

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

	var ans string
	if cnt <= 2 {
		ans = "YES"
	} else {
		ans = "NO"
	}
	fmt.Fprintln(out, ans)
}
func main() {
	t := 0
	fmt.Fscan(in, &t)
	defer out.Flush()
	for i := 0; i < t; i++ {
		//	fmt.Printf("i: %v\n", i)
		solve()
	}
}

package main

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

var st [55]bool

func init() {
	for i := 0; i <= 50; i += 2 {
		for j := 0; i+j <= 50; j += 3 {
			st[i+j] = true
		}
	}
}

var (
	in  *bufio.Reader = bufio.NewReader(os.Stdin)
	out *bufio.Writer = bufio.NewWriter(os.Stdout)
)

func solve() {
	// in := bufio.NewReader(os.Stdin)
	// s, _ := in.ReadString('\n')
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &v[i])
	}
	cnt := 0
	for i := 1; i < n; i++ {
		cnt += v[i] - v[i-1] - 1
	}

	var ans string
	if cnt <= 2 {
		ans = "YES"
	} else {
		ans = "NO"
	}
	fmt.Fprintln(out, ans)
}
func main() {
	t := 0
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		//	fmt.Printf("i: %v\n", i)
		solve()
	}
}

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 ttmp := 0; ttmp < t; ttmp++ {
		var N int
		fmt.Fscan(in, &N)
		numbers := make([]int, N)
		for i := 0; i < N; i++ {
			fmt.Fscan(in, &numbers[i])
		}
		sum := 0
		for i := 1; i < N; i++ {
			sum += (numbers[i] - numbers[i-1] - 1)
		}
		if sum <= 2 {
			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 ttmp := 0; ttmp < t; ttmp++ {
		var N int
		fmt.Fscan(in, &N)
		numbers := make([]int, N)
		for i := 0; i < N; i++ {
			fmt.Fscan(in, &numbers[i])
		}
		sum := 0
		for i := 1; i < N; i++ {
			sum += (numbers[i] - numbers[i-1] - 1)
		}
		if sum <= 2 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}

}

package main

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

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

func solve() {
	var N int
	fmt.Fscan(in, &N)
	//arr := make([]int64, N)

	check := true
	prev := 0

	ans := true

	for i := 0; i < N; i++ {
		//fmt.Fscan(in, &arr[i])
		var k int
		fmt.Fscan(in, &k)

		if i > 0 {
			switch dif := k - prev; dif {
			case 1:
				prev = k
			case 2:
				if check {
					prev = k
					check = false
				} else {
					prev = k - 1
				}
			case 3:
				if check {
					prev = k - 1
					check = false
				} else {
					ans = false
				}
			default:
				ans = false

			}
		} else {
			prev = k
		}
	}
	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {
	defer out.Flush()

	var N int
	fmt.Fscan(in, &N)

	for n := 0; n < N; n++ {
		solve()
	}

}

package main

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

const MOD int64 = 1000000007

var n int

var p []int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

func main() {

	read := bufio.NewReader(os.Stdin)

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

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

		fmt.Fscan(read, &n)

		p = make([]int, n)

		for i := 0; i < n; i++ {
			fmt.Fscan(read, &p[i])
		}

		solve()
	}
}

type pair struct {
	v int
	idx []int
}

//a b c d

//20 12 -- 4
//4  2  -- 4

func solve()  {
	if n == 1 {
		fmt.Println("YES")
		return
	}

	prev := p[0] - 1

	res := true

	for i := 1; i < n; i++ {
		if p[i] - 2 == prev {
			prev = p[i] - 1
			continue
		}
		res = false
		break
	}

	if res {
		fmt.Println("YES")
		return
	}

	res = true
	prev = p[0]

	for i := 1; i < n; i++ {
		if p[i] - 1 == prev {
			prev = p[i]
			continue
		} else if p[i] - 2 == prev {
			prev = p[i] - 1
			continue
		}
		res = false
		break
	}

	if res {
		fmt.Println("YES")
		return
	}

	res = true
	prev = p[0] + 1

	for i := 1; i < n; i++ {
		if p[i] == prev {
			prev = p[i] + 1
			continue
		}
		if p[i] - 1 == prev {
			prev = p[i]
			continue
		} else if p[i] - 2 == prev {
			prev = p[i] - 1
			continue
		}
		res = false
		break
	}

	if res {
		fmt.Println("YES")
		return
	}

	fmt.Println("NO")
}

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

package main

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

const (
	INF = 3e5 + 10
	L0  = int64(0)
	L1  = int64(1)
)

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

	var t int
	Fscan(in, &t)

	for tt := 0; tt < t; tt++ {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}
		left := true
		right := true
		ans := "YES"
		for i := 1; i < n; i++ {
			if a[i]-a[i-1] == 1 {
				continue
			} else if a[i]-a[i-1] == 2 {
				if left {
					left = false
				} else if right {
					right = false
				} else {
					ans = "NO"
					break
				}
			} else if a[i]-a[i-1] == 3 {
				if left && right {
					left = false
					right = false
				} else {
					ans = "NO"
					break
				}
			} else {
				ans = "NO"
				break
			}
		}
		Fprintln(out, ans)
	}
}

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

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

// https://codeforces.com/problemset/problem/1671/B

// 1671B - Consecutive Points Segment

// You are given n points with integer coordinates on a coordinate axis OX. The coordinate of the i-th point is xi. All points' coordinates are distinct and given in strictly increasing order.
// For each point i, you can do the following operation no more than once: take this point and move it by 1 to the left or to the right (i..e., you can change its coordinate xi to xi−1 or to xi+1). In other words, for each point, you choose (separately) its new coordinate. For the i-th point, it can be either xi−1, xi or xi+1.
// Your task is to determine if you can move some points as described above in such a way that the new set of points forms a consecutive segment of integers, i. e. for some integer l the coordinates of points should be equal to l,l+1,…,l+n−1.
// Note that the resulting points should have distinct coordinates.
// You have to answer t independent test cases.

// Input
// The first line of the input contains one integer t (1≤t≤2⋅10^4) — the number of test cases. Then t test cases follow.
// The first line of the test case contains one integer n (1≤n≤2⋅10^5) — the number of points in the set x.
// The second line of the test case contains n integers x1<x2<…<xn (1≤xi≤10^6), where xi is the coordinate of the i-th point.
// It is guaranteed that the points are given in strictly increasing order (this also means that all coordinates are distinct). It is also guaranteed that the sum of n does not exceed 2⋅10^5 (∑n≤2⋅10^5).

// Output
// For each test case, print the answer — if the set of points from the test case can be moved to form a consecutive segment of integers, print YES, otherwise print NO.

// Example
// input
// 5
// 2
// 1 4
// 3
// 1 2 3
// 4
// 1 2 3 7
// 1
// 1000000
// 3
// 2 5 6
// output
// YES
// YES
// NO
// YES
// YES

// Tutorial

// We can see that the answer is YES if and only if there are no more than two gaps of length 1 between the given points. If there is no gap, the answer is obviously YES. If there is only one gap of length 1, we can just move the left (or the right) part of the set to this gap. When there are two gaps, we can move the part before the first gap to the right and the part after the second gap to the left. Of course, if there is a gap of length at least 3 (or multiple gaps with the total length 3), we can't move the points from the left and the right part to satisfy the middle gap.
// Time complexity: O(n).

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c int
	var t, n, i, first_x, last_x uint

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &n)

			fmt.Fscan(reader, &first_x)

			for i = 1; i < n; i++ {
				fmt.Fscan(reader, &last_x)
			}

			if last_x <= n+first_x+1 {
				fmt.Fprintln(writer, "YES")
			} else {
				fmt.Fprintln(writer, "NO")
			}
		}
	}

	writer.Flush()
}

package main

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

func test(a []int) {
	a[0] = 1
}

var (
	in  *bufio.Reader = bufio.NewReader(os.Stdin)
	out *bufio.Writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t, "\n")
	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}

		flag := false
		for i := -1; i < 2; i++ {
			for j := -1; j < 2; j++ {
				tmp := make([]int, n)
				copy(tmp, arr)
				tmp[0] += i
				tmp[n-1] += j
				f := true
				for k := 1; k < n-1; k++ {
					want := tmp[k-1] + 1
					if want == tmp[k] {
						continue
					}
					if want == tmp[k]+1 {
						tmp[k] += 1
					} else if want == tmp[k]-1 {
						tmp[k] -= 1
					} else {
						f = false
						break
					}
				}
				if n > 1 && tmp[n-1]-1 != tmp[n-2] {
					f = false
				}
				flag = flag || f
			}
		}

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

package main

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

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

	var T, n int
O:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
	o:
		for l := a[0] - 1; l < a[0]+2; l++ {
			for i, v := range a {
				if abs(l+i-v) > 1 {
					continue o
				}
			}
			Fprintln(out, "YES")
			continue O
		}
		Fprintln(out, "NO")
	}
}

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

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

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)

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

		var d int
		for i := 1; i < n; i++ {
			d += arr[i] - arr[i-1] - 1
		}

		if d <= 2 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}

	}
}

package main

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

/*
5
1
5
4
1 3 5 7
3
1 3 5
3
1 3 6
7
1 2 4 6 7 9 12
---
YES
NO
YES
NO
NO
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	x := make([]int, n)

	for i := range x {
		scanf("%d", &x[i])
	}
	scanf("\n")

	gapToCnt := make(map[int]int)

	for i, lft := range x[:n-1] {
		rht := x[i+1]

		gap := rht - lft
		if gap > 3 {
			fmt.Fprintln(writer, "NO")
			return
		}

		gapToCnt[gap]++
	}

	if gapToCnt[3] > 1 {
		fmt.Fprintln(writer, "NO")
		return
	}

	if gapToCnt[2] > 2 {
		fmt.Fprintln(writer, "NO")
		return
	}

	if gapToCnt[3] > 0 && gapToCnt[2] > 0 {
		fmt.Fprintln(writer, "NO")
		return
	}

	fmt.Fprintln(writer, "YES")
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

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

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

//goland:noinspection GoUnhandledErrorResult
func factorize(num int) []int {
	factors := []int{1}

	sqrtA := int(math.Sqrt(float64(num)))

	for ftr := 2; ftr <= sqrtA; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > sqrtA {
		factors = append(factors, num)
	}

	return factors
}

package main

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

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

func CF1671B(_r io.Reader, _w io.Writer) {
	in, out := bufio.NewReader(_r), bufio.NewWriter(_w)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		n := 0
		fmt.Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			fmt.Fscan(in, &a[i])
		}
		b := make([]int, n)
		p := [3]int{0, 1, -1}
		for _, v := range p {
			b[0] = a[0] + v
			for i := 1; i < n; i++ {
				b[i] = b[i-1] + 1
			}
			for i := range a {
				if a[i]-b[i] != 0 && a[i]-b[i] != 1 && a[i]-b[i] != -1 {
					goto h1
				}
			}
			fmt.Fprintln(out, "YES")
			goto h2
		h1:
		}
		fmt.Fprintln(out, "NO")
	h2:
	}
}

package main

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

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

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

	var T int
	var x int
	var n int

loop:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)

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

		pre := r[0] + 1
		for i := 1; i < n; i++ {
			if r[i]-pre > 2 {
				Fprintln(out, "NO")
				continue loop
			}
			if r[i]-pre == 2 {
				pre = r[i] - 1
			} else if r[i]-pre == 1 {
				pre = r[i]
			} else if r[i] == pre {
				pre = r[i] + 1
			}
		}

		Fprintln(out, "YES")
	}
}

package main

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

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

func main() {
	defer out.Flush()

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n int
		fmt.Fscan(in, &n)
		xs := make([]int, n)
		for i := range xs {
			fmt.Fscan(in, &xs[i])
		}
		ok := false
		if !ok {
			ok = true
			cur := xs[0] - 1
			for _, x := range xs {
				if cur-x < -1 || 1 < cur-x {
					ok = false
					break
				}
				cur++
			}
		}
		if !ok {
			ok = true
			cur := xs[0]
			for _, x := range xs {
				if cur-x < -1 || 1 < cur-x {
					ok = false
					break
				}
				cur++
			}
		}
		if !ok {
			ok = true
			cur := xs[0] + 1
			for _, x := range xs {
				if cur-x < -1 || 1 < cur-x {
					ok = false
					break
				}
				cur++
			}
		}
		if !ok {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i := range nums {
		fmt.Fscan(r, &nums[i])
	}
	outer:
	for i:=nums[0]-1;i<=nums[0]+1;i++ {
		for j:=i;j<i+n;j++ {
			if abs(j-nums[j-i]) > 1 {
				continue outer
			}
		}
		fmt.Fprintln(w, "Yes")
		return
	}
	fmt.Fprintln(w, "No")
}

func abs(a int) int {if a < 0 {return -a} else {return a}}
//func max(a, b int) int {if a > b {return a} else {return b}}

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

// 00
package main

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

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		ok := true
		two_count := 0
		three_count := 0

		for i := 1; i < n; i++ {
			diff := a[i] - a[i-1]
			if diff > 3 {
				ok = false
				break
			} else if diff > 1 {
				if diff == 2 {
					two_count++
				} else {
					three_count++
				}
				if two_count > 2 || three_count > 1 || three_count > 1 && two_count > 1 {
					ok = false
					break
				}

			}
		}
		if ok {
			write(f, "YES\n")
		} else {
			write(f, "NO\n")
		}
	}
}

// 00
package main

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

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		ok := true
		two_count := 0
		three_count := 0

		for i := 1; i < n; i++ {
			diff := a[i] - a[i-1]
			if diff > 3 {
				ok = false
				break
			} else if diff > 1 {
				if diff == 2 {
					two_count++
				} else {
					three_count++
				}
				if two_count > 2 || three_count > 1 {
					ok = false
					break
				}

			}
		}
		if ok {
			write(f, "YES\n")
		} else {
			write(f, "NO\n")
		}
	}
}

// 00
package main

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

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		ok := true
		used := false

		for i := 1; i < n; i++ {
			if a[i]-a[i-1] > 3 {
				ok = false
				break
			} else if a[i]-a[i-1] > 1 {
				if used {
					ok = false
					break
				} else {
					used = true
				}
			}
		}
		if ok {
			write(f, "YES\n")
		} else {
			write(f, "NO\n")
		}
	}
}

// 00
package main

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

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		ok := true
		used := false

		for i := 1; i < n; i++ {
			if a[i]-a[i-1] > 3 {
				ok = false
				break
			} else if a[i]-a[i] > 1 {
				if used {
					ok = false
					break
				} else {
					used = true
				}
			}
		}
		if ok {
			write(f, "YES\n")
		} else {
			write(f, "NO\n")
		}
	}
}

package main

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

const maxTokenSize = 2500000 * 7

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, maxTokenSize), maxTokenSize)
	scanner.Scan()

	count, _ := strconv.Atoi(scanner.Text())

out:
	for i := 0; i < count; i++ {
		scanner.Scan()
		dotsCount, _ := strconv.Atoi(scanner.Text())

		var dots []int
		scanner.Scan()
		for _, dot := range strings.Split(scanner.Text(), " ") {
			d, _ := strconv.Atoi(dot)
			dots = append(dots, d)
		}

		if dotsCount == 1 {
			fmt.Println("YES")
			continue
		}

		for i := range dots {
			if i == 0 {
				continue
			}

			if i == len(dots)-1 {
				if dots[i]-dots[i-1] > 3 {
					fmt.Println("NO")
					continue out
				}
				break
			}

			if dots[i]-dots[i-1] > 3 || dots[i+1]-dots[i] > 3 {
				fmt.Println("NO")
				continue out
			}

			if (dots[i]-dots[i-1])+(dots[i+1]-dots[i]) >= 5 {
				fmt.Println("NO")
				continue out
			}
		}

		fmt.Println("YES")
	}
}

package main

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

const maxTokenSize = 2500000 * 7

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, maxTokenSize), maxTokenSize)
	scanner.Scan()

	count, _ := strconv.Atoi(scanner.Text())

out:
	for i := 0; i < count; i++ {
		scanner.Scan()
		dotsCount, _ := strconv.Atoi(scanner.Text())

		var dots []int
		scanner.Scan()
		for _, dot := range strings.Split(scanner.Text(), " ") {
			d, _ := strconv.Atoi(dot)
			dots = append(dots, d)
		}

		if dotsCount == 1 {
			fmt.Println("YES")
			continue
		}

		for i := range dots {
			if i == 0 {
				continue
			}

			if i == len(dots)-1 {
				if dots[i]-dots[len(dots)-1] > 3 {
					fmt.Println("NO")
					continue out
				}
				break
			}

			if dots[i]-dots[i-1] > 3 || dots[i+1]-dots[i] > 3 {
				fmt.Println("NO")
				continue out
			}

			if (dots[i]-dots[i-1])+(dots[i+1]-dots[i]) >= 5 {
				fmt.Println("NO")
				continue out
			}
		}

		fmt.Println("YES")
	}
}

package main

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

const maxTokenSize = 2500000 * 7

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, maxTokenSize), maxTokenSize)
	scanner.Scan()

	count, _ := strconv.Atoi(scanner.Text())

out:
	for i := 0; i < count; i++ {
		scanner.Scan()
		dotsCount, _ := strconv.Atoi(scanner.Text())

		var dots []int
		scanner.Scan()
		for _, dot := range strings.Split(scanner.Text(), " ") {
			d, _ := strconv.Atoi(dot)
			dots = append(dots, d)
		}

		if dotsCount == 1 {
			fmt.Println("YES")
			continue
		}

		prevDot := dots[0]
		for _, dot := range dots[1:] {
			if dot - prevDot > 3 {
				fmt.Println("NO")
				continue out
			}

			prevDot = dot
		}

		fmt.Println("YES")
	}
}

package main

import (
	"fmt"
)

var st [55]bool

func init() {
	for i := 0; i <= 50; i += 2 {
		for j := 0; i+j <= 50; j += 3 {
			st[i+j] = true
		}
	}
}

func solve() {
	// in := bufio.NewReader(os.Stdin)
	// s, _ := in.ReadString('\n')
	var n int
	fmt.Scan(&n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	cnt := 0
	for i := 1; i < n; i++ {
		cnt += v[i] - v[i-1] - 1
	}

	var ans string
	if cnt <= 2 {
		ans = "YES"
	} else {
		ans = "NO"
	}
	println(ans)
}
func main() {
	t := 0
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		//	fmt.Printf("i: %v\n", i)
		solve()
	}
}

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 ttmp := 0; ttmp < t; ttmp++ {
		var N int
		fmt.Fscan(in, &N)
		numbers := make([]int, N)
		for i := 0; i < N; i++ {
			fmt.Fscan(in, &numbers[i])
		}
		sum := 0
		for i := 1; i < N; i++ {
			sum += (numbers[i] - numbers[i-1] - 1)
		}
		if sum <= 2 {
			fmt.Println(out, "YES")
		} else {
			fmt.Println(out, "NO")
		}
	}

}

package main

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

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

func solve() {
	var N int
	fmt.Fscan(in, &N)
	//arr := make([]int64, N)

	check := true
	prev := 0

	ans := true

	for i := 0; i < N; i++ {
		//fmt.Fscan(in, &arr[i])
		var k int
		fmt.Fscan(in, &k)

		fmt.Println(k-prev, check)
		if i > 0 {
			switch dif := k - prev; dif {
			case 1:
				prev = k
			case 2:
				if check {
					prev = k
					check = false
				} else {
					prev = k - 1
				}
			case 3:
				if check {
					prev = k - 1
					check = false
				} else {
					ans = false
				}
			default:
				ans = false

			}
		} else {
			prev = k
		}
	}
	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {
	defer out.Flush()

	var N int
	fmt.Fscan(in, &N)

	for n := 0; n < N; n++ {
		solve()
	}

}

package main

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

const MOD int64 = 1000000007

var n int

var p []int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

func main() {

	read := bufio.NewReader(os.Stdin)

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

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

		fmt.Fscan(read, &n)

		p = make([]int, n)

		for i := 0; i < n; i++ {
			fmt.Fscan(read, &p[i])
		}

		solve()
	}
}

type pair struct {
	v int
	idx []int
}

//a b c d

//20 12 -- 4
//4  2  -- 4

func solve()  {
	if n == 1 {
		fmt.Println("YES")
		return
	}

	prev := p[0] - 1

	res := true

	for i := 1; i < n; i++ {
		if p[i] - 1 == prev + 1 {
			prev = p[i] - 1
			continue
		}
		res = false
		break
	}

	if res {
		fmt.Println("YES")
		return
	}

	res = true
	prev = p[0]

	for i := 1; i < n; i++ {
		if p[i] - 1 == prev {
			prev = p[i]
			continue
		} else if p[i] - 2 == prev {
			prev = p[i] - 1
			continue
		}
		res = false
		break
	}

	if res {
		fmt.Println("YES")
		return
	}

	res = true
	prev = p[0] + 1

	for i := 1; i < n; i++ {
		if p[i] - 1 == prev {
			prev = p[i]
			continue
		} else if p[i] - 2 == prev {
			prev = p[i] - 1
			continue
		}
		res = false
		break
	}

	if res {
		fmt.Println("YES")
		return
	}

	fmt.Println("NO")
}

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

package main

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

const (
	INF = 3e5 + 10
	L0  = int64(0)
	L1  = int64(1)
)

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

	var t int
	Fscan(in, &t)

	for tt := 0; tt < t; tt++ {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}
		left := true
		right := true
		ans := "YES"
		for i := 1; i < n; i++ {
			if a[i]-a[i-1] == 1 {
				continue
			} else if a[i]-a[i-1] == 2 {
				if left {
					left = false
				} else {
					ans = "NO"
					break
				}
			} else if a[i]-a[i-1] == 3 {
				if left && right {
					left = false
					right = false
				} else {
					ans = "NO"
					break
				}
			} else {
				ans = "NO"
			}
		}
		Fprintln(out, ans)
	}
}

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

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


God's Blessing on This PermutationForces!A Random PebbleYou are given a permutation $$$p_1,p_2,\ldots,p_n$$$ of length $$$n$$$ and a positive integer $$$k \le n$$$. In one operation you can choose two indices $$$i$$$ and $$$j$$$ ($$$1 \le i < j \le n$$$) and swap $$$p_i$$$ with $$$p_j$$$.Find the minimum number of operations needed to make the sum $$$p_1 + p_2 + \ldots + p_k$$$ as small as possible.A permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 100$$$). The second line of each test case contains $$$n$$$ integers $$$p_1,p_2,\ldots,p_n$$$ ($$$1 \le p_i \le n$$$). It is guaranteed that the given numbers form a permutation of length $$$n$$$.

For each test case print one integer — the minimum number of operations needed to make the sum $$$p_1 + p_2 + \ldots + p_k$$$ as small as possible.

NoteIn the first test case, the value of $$$p_1 + p_2 + \ldots + p_k$$$ is initially equal to $$$2$$$, but the smallest possible value is $$$1$$$. You can achieve it by swapping $$$p_1$$$ with $$$p_3$$$, resulting in the permutation $$$[1, 3, 2]$$$.In the second test case, the sum is already as small as possible, so the answer is $$$0$$$.

package main

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

func main() {
	wonderfulPermutationRead()
}

func wonderfulPermutationRead() {
	in := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		var n, k int

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

		arr := make([]int, n)

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

		// solve
		res := wonderfulPermutation(arr, n, k)
		fmt.Println(res)
	}
}

func wonderfulPermutation(arr []int, n, k int) int {
	if n == k {
		return 0
	}

	seen := make(map[int]bool)
	for i := 0; i < k; i++ {
		seen[arr[i]] = true
	}
	sort.Ints(arr)

	count := 0
	for i := 0; i < k; i++ {
		if !seen[arr[i]] {
			count++
		}
	}
	return count
}

package main
import(
    "fmt"
    "bufio"
    "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 i:=0;i<t;i++{
		var n,x int
		fmt.Fscan(in,&n,&x)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			mapper[j]= list[j]
		}
		sort.Ints(list)
		counter:=0
		for j:=0;j<x;j++{
			if mapper[j] <= list[x-1] {
				continue
			} else {
				counter++
			}
		}
		fmt.Fprintln(out,counter)
	}
}

package main

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

var (
	reader bufio.Reader
	writer bufio.Writer
)

func solve() {
	var n, k int
	scan(&n, &k)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		scan(&a[i])
	}

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

	printf("%v\n", ans)
}

func main() {
	inp, err := os.Open("in.txt")
	if err == nil {
		os.Stdin = inp
		outp, _ := os.Create("out.txt")
		os.Stdout = outp
		defer outp.Close()
		defer inp.Close()
	}
	reader = *bufio.NewReader(os.Stdin)
	writer = *bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var T int
	T = 1
	scan(&T)

	for ; T > 0; T-- {
		solve()
	}
}

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(&reader, a...)
}

func printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(&writer, format, a...)
}

package main

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

var (
	reader bufio.Reader
	writer bufio.Writer
)

func solve() {
	var n, k int
	scan(&n, &k)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		scan(&a[i])
	}

	var ans = 0
	for i := k; i < n; i++ {
		if a[i] <= k {
			ans++
		}
	}

	printf("%v\n", ans)
}

func main() {
	inp, err := os.Open("in.txt")
	if err == nil {
		os.Stdin = inp
		outp, _ := os.Create("out.txt")
		os.Stdout = outp
		defer outp.Close()
		defer inp.Close()
	}
	reader = *bufio.NewReader(os.Stdin)
	writer = *bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var T int
	T = 1
	scan(&T)

	for ; T > 0; T-- {
		solve()
	}
}

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(&reader, a...)
}

func printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(&writer, format, a...)
}

package main

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

func readLine() string {
	s, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readLines(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = readLine()
	}
	return res
}

func readInt() int {
	n, err := strconv.ParseInt(readLine(), 10, 32)
	if err != nil {
		panic(err)
	}
	return int(n)
}

func readInt2() (int, int) {
	as := readInts(2)
	return as[0], as[1]
}

func readInt3() (int, int, int) {
	as := readInts(3)
	return as[0], as[1], as[2]
}

func readUint() uint64 {
	n, err := strconv.ParseUint(readLine(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

func readStrings(n int) []string {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	return as
}

func arr(n, m int) [][]int {
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	return a
}

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

func main() {
	var t, n, k int
	t = readInt()
	for ; t != 0; t-- {
		n, k = readInt2()
		a := readInts(n)
		ans := 0
		for i := 1; i <= k; i++ {
			if a[i-1] <= k {
				ans++
			}
		}
		fmt.Println(k - ans)
	}
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--

		n, k := readTwoNums(reader)
		P := readNNums(reader, n)
		res := solve(k, P)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(k int, P []int) int {
	// n := len(P)
	// want 1...k
	var res int
	for i := 0; i < k; i++ {
		if P[i] > k {
			res++
		}
	}
	return res
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func solve() {
	var n, k int
	scan(&n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scan(&a[i])
	}
	count := 0
	for i := 0; i < k; i++ {
		if a[i] <= k {
			count++
		}
	}
	printf("%d\n", k-count)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

type CF1712A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1712A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1712A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1712A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1712A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1712A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1712A
Date: 18/08/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1712/A
Problem: CF1712A
**/
func (in *CF1712A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, k := in.NextInt(), in.NextInt()
		p := make([]int, n)
		mapa := make(map[int]int)
		for i := 0; i < n; i++ {
			p[i] = in.NextInt()
			if i < k {
				mapa[p[i]]++
			}
		}
		sort.Ints(p)
		ans := 0
		for i := 0; i < k; i++ {
			if v, e := mapa[p[i]]; e {
				mapa[p[i]] = v - 1
			} else {
				ans++
			}
		}
		fmt.Println(ans)
	}
}

func NewCF1712A(r *bufio.Reader) *CF1712A {
	return &CF1712A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1712A(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"fmt"
	"os"
)

func main() {
	in := os.Stdin
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n, k int
		fmt.Fscan(in, &n)
		fmt.Fscan(in, &k)
		temp := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &temp[j])
		}
		//fmt.Println("temp: ", temp)
		s, e := 0, n-1
		ans := 0
		for s < k {
			if temp[s] <= k {
				s++
				continue
			}
			if temp[e] > k {
				e--
				continue
			}
			temp[s], temp[e] = temp[e], temp[s]
			ans++
		}
		fmt.Println(ans)
	}
}

package main

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

var bufferedStdin = bufio.NewReader(os.Stdin)
var bufferedStdout = bufio.NewWriter(os.Stdout)

func read(value ...interface{}) {
	_, _ = fmt.Fscan(bufferedStdin, value...)
}

func printf(format string, value ...interface{}) {
	_, _ = fmt.Fprintf(bufferedStdout, format, value...)
}

func printfErr(format string, value ...interface{}) {
	_, _ = fmt.Fprintf(os.Stderr, format, value...)
}

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

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

func findElementIds(array []int, f func(int) bool) []int {
	var result = make([]int, 0)
	for i := 0; i < len(array); i++ {
		if f(array[i]) {
			result = append(result, i)
		}
	}
	return result
}

func reduce(array []int, defaultValue int, f func(int, int) int) int {
	for i := 0; i < len(array); i++ {
		defaultValue = f(defaultValue, array[i])
	}
	return defaultValue
}

func solve(test int) {
	var n, k int
	_, _ = fmt.Fscan(bufferedStdin, &n, &k)
	var ans = 0
	for i := 0; i < n; i++ {
		var a int
		_, _ = fmt.Fscan(bufferedStdin, &a)
		if a > k && i < k {
			ans++
		}
	}
	_, _ = fmt.Fprintf(bufferedStdout, "%d\n", ans)
}

func main() {
	var t = 1
	_, _ = fmt.Fscan(bufferedStdin, &t)
	for i := 0; i < t; i++ {
		solve(i + 1)
	}
	_ = bufferedStdout.Flush()
}

package main

import (
	"fmt"
)

func solve() {
	var n, k int
	fmt.Scan(&n, &k)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	var cnt int
	for i := 0; i < k; i++ {
		if arr[i] > k {
			cnt++
		}
	}
	fmt.Printf("%d\n", cnt)
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solve()
	}

}

package main

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

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

func main() {
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n, k int
		fmt.Fscan(in, &n, &k)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}
		mmid := make(map[int]int)
		for i := 0; i < k; i++ {
			mmid[arr[i]] = 1
		}
		var ans int
		for i := 1; i <= k; i++ {
			if _, ok := mmid[i]; !ok {
				ans++
			}
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

func Solve(_in io.Reader, _out io.Writer) {
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var t, n, k, ans int
	for Fscan(in, &t); t > 0; t-- {
		ans = 0
		Fscan(in, &n, &k)
		a, b := make([]int, n+1), make([]int, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			b[i] = a[i]
		}
		sort.Ints(b)
		for i := n; i > k; i-- {
			if a[i] <= b[k] { ans++ }
		}
		Fprintln(out, ans)
	}
}

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

package main

import "fmt"

func main() {

	t := 0
	if _, err := fmt.Scan(&t); err != nil {
		return
	}
	for ; t > 0; t-- {
		n, k, ans := 0, 0, 0
		if _, err := fmt.Scan(&n, &k); err != nil {
			return
		}
		for i := 0; i < n; i++ {
			p := 0
			if _, err := fmt.Scan(&p); err != nil {
				return
			}
			if i < k && p > k {
				ans++
			}
		}
		fmt.Println(ans)
	}

}

// 00
package main

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n, k int
		fmt.Fscan(reader, &n, &k)
		a := make([]int, n)
		ans := 0
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
			if i < k && a[i] > k {
				ans++
			}
		}
		fmt.Println(ans)
	}
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scan(&T)
	for t := 0; t < T; t++ {
		var n, k int
		fmt.Scan(&n, &k)
		var x int
		ans := 0
		for i := 0; i < n; i++ {
			fmt.Scan(&x)
			if x > k && i+1 <= k {
				ans++
			}
		}
		fmt.Println(ans)
	}

}

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)

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

		var tot int
		for i := 0; i < k; i++ {
			if aa[i] <= k {
				tot++
			}
		}
		fmt.Fprintln(out, k-tot)
	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		tmp := readArrInt(input)
		n := tmp[0]
		k := tmp[1]
		arr := readArrInt(input)
		fmt.Println(solve(n, k, arr))
	}
}

func solve(n int, k int, arr []int) int {
	result := 0
	for i := 0; i < k; i++ {
		if arr[i] > k {
			result++
		}
	}
	return result
}

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

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return int64(n)
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

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

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

func main() {
	defer out.Flush()

	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		fmt.Fprintln(out, solve())
	}
}

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

	if k == n {
		return 0
	}

	i := 0
	j := k
	res := 0
	for {
		for i < k && a[i] <= k {
			i++
		}
		for j < n && a[j] > k {
			j++
		}
		if i < k && j < n {
			res++
			i++
			j++
		} else {
			break
		}
	}
	return res
}

package main

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

const cf = true

func solve() {
	var n, k int
	fmt.Fscan(in, &n, &k)
	arr := make([]int, n)
	ans := 0
	for i := range arr {
		fmt.Fscan(in, &arr[i])
		if i < k && arr[i] > k {
			ans++
		}
	}
	fmt.Fprintln(out, ans)
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

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

func A0() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	// Coding...beg!
	sol = func() {
		var n, k, ans int

		Fscan(in, &n, &k)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}
		for i := k; i < n; i++ {
			if a[i] <= k {
				ans++
			}
		}
		Fprintln(out, ans)
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}
func main() { A0() }

package main

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

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

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

// func maxSquare(a int) int {
// 	tmp := int(math.Sqrt(float64(a)))
// 	if tmp*tmp == a {
// 		return tmp * tmp
// 	} else {
// 		return (tmp + 1) * (tmp + 1)
// 	}
// }

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var niter int
	fmt.Fscan(in, &niter)
	for iiter := 0; iiter < niter; iiter++ {
		var n, k int
		fmt.Fscan(in, &n, &k)
		slc := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &slc[i])
		}
		res := 0
		for i := 0; i < k; i++ {
			if slc[i] > k {
				res++
			}
		}
		fmt.Fprintln(out, res)
	}
}

package main

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

func main() {
	wonderfulPermutationRead()
}

func wonderfulPermutationRead() {
	in := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		var n, k int

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

		arr := make([]int, n)

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

		// solve
		res := wonderfulPermutation(arr, n, k)
		fmt.Print(res)
	}
}

func wonderfulPermutation(arr []int, n, k int) int {
	if n == k {
		return 0
	}

	seen := make(map[int]bool)
	for i := 0; i < k; i++ {
		seen[arr[i]] = true
	}
	sort.Ints(arr)

	count := 0
	for i := 0; i < k; i++ {
		if !seen[arr[i]] {
			count++
		}
	}
	return count
}

package main

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

func main() {
	wonderfulPermutationRead()
}

func wonderfulPermutationRead() {
	in := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscan(in, &t)
	ra := make([]int, t)

	for i := 0; i < t; i++ {
		var n, k int

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

		arr := make([]int, n)

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

		// solve
		res := wonderfulPermutation(arr, n, k)
		ra[i] = res
	}
	for _, res := range ra {
		fmt.Print(res)
	}
}

func wonderfulPermutation(arr []int, n, k int) int {
	if n == k {
		return 0
	}

	temp := make([]int, n)
	copy(temp, arr)
	sort.Ints(temp)
	seen := make(map[int]bool)

	for i := 0; i < k; i++ {
		seen[arr[i]] = true
	}

	count := 0
	for i := 0; i < k; i++ {
		if !seen[temp[i]] {
			count++
		}
	}
	return count
}

package main

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

func main() {
	wonderfulPermutationRead()
}

func wonderfulPermutationRead() {
	in := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		var n, k int

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

		arr := make([]int, n)

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

		// solve
		res := wonderfulPermutation(arr, n, k)
		fmt.Print(res)
	}
}

func wonderfulPermutation(arr []int, n, k int) int {
	if n == k {
		return 0
	}

	temp := make([]int, n)
	copy(temp, arr)
	sort.Ints(temp)
	seen := make(map[int]bool)

	for i := 0; i < k; i++ {
		seen[arr[i]] = true
	}

	count := 0
	for i := 0; i < k; i++ {
		if !seen[temp[i]] {
			count++
		}
	}
	return count
}

package main
import(
    "fmt"
    "bufio"
    "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 i:=0;i<t;i++{
		var n,x int
		fmt.Fscan(in,&n,&x)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			mapper[j]= list[j]
		}
		sort.Ints(list)
		counter:=0
		for j:=0;j<x;j++{
			if mapper[j] <= list[j] {
				continue
			} else {
				counter++
			}
		}
		fmt.Fprintln(out,counter)
	}
}

package main

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

func readLine() string {
	s, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readLines(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = readLine()
	}
	return res
}

func readInt() int {
	n, err := strconv.ParseInt(readLine(), 10, 32)
	if err != nil {
		panic(err)
	}
	return int(n)
}

func readInt2() (int, int) {
	as := readInts(2)
	return as[0], as[1]
}

func readInt3() (int, int, int) {
	as := readInts(3)
	return as[0], as[1], as[2]
}

func readUint() uint64 {
	n, err := strconv.ParseUint(readLine(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

func readStrings(n int) []string {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	return as
}

func arr(n, m int) [][]int {
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	return a
}

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

func main() {
	var t, n, k int
	t = readInt()
	for ; t != 0; t-- {
		n, k = readInt2()
		a := readInts(n)
		ans := 0
		for i := 1; i <= k; i++ {
			if i == a[i-1] {
				continue
			}
			for j := i + 1; j <= n; j++ {
				if a[j-1] == i {
					a[j-1], a[i-1] = a[i-1], a[j-1]
					ans++
					break
				}
			}
		}
		fmt.Println(ans)
	}
}


Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handkerchief pattern should look like that:           0        0 1 0      0 1 2 1 0    0 1 2 3 2 1 0  0 1 2 3 4 3 2 1 00 1 2 3 4 5 4 3 2 1 0  0 1 2 3 4 3 2 1 0    0 1 2 3 2 1 0      0 1 2 1 0        0 1 0          0Your task is to determine the way the handkerchief will look like by the given n.

The first line contains the single integer n (2 ≤ n ≤ 9).

Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line.

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	_,er := fmt.Scan(&n)
	if er != nil {
		os.Exit(1)
	}
	for i := -n; i <= n; i++ {
		for j := 0; j < abs(i); j++ {
			fmt.Print("  ")
		}
		max_num := n - abs(i)
		for j := 0; j < 2*max_num; j++ {
			fmt.Printf("%d ", min(j,abs(2*max_num-j)))
		}
		fmt.Println("0")
	}
}

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

func min(num1 int, num2 int) int{
	if num1 < num2{
		return num1
	}else{
		return num2
	}
}

package main
import (
	"fmt"
)
func main() {
	var n int
	fmt.Scan(&n)
	m :=0
	t:=0
	for r:=-n; r<=n; r++ {
		if r<0 {
			m=r*(-1)
		} else {m=r}
		t= n-m
		for j:=0;j<m;j++ {
			fmt.Printf("  ")
		}
		for i:=0;i<t;i++ {
			fmt.Printf("%d ",i)
		}
		for i:=t;i>0;i-- {
			fmt.Printf("%d ",i)
		}
		fmt.Println("0")
	}
}

package main

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

var scanner *bufio.Scanner

func getI() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := int(getI())
  for i := 0; i < 2*n+1; i++ {
    limit := i
    if limit > n {
      limit = 2*n - limit
    }
    for j := limit; j < n; j++ {
      writer.WriteString("  ")
    }
    writer.WriteString("0")
    if limit != 0 {
      for j := 1; j < limit; j++ {
        writer.WriteString(fmt.Sprintf(" %d", j))
      }
      for j := limit; j >= 0; j-- {
        writer.WriteString(fmt.Sprintf(" %d", j))
      }
    }
    writer.WriteString("\n")
  }
}

package main

import (
	"fmt"
)

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

	for t := 0; t < 2*n-1; t++ {
		var i int
		if t < n {
			i = t
		} else {
			i = 2*(n-1) - t
		}
		for j := i + 1; j < n*2-(i+1); j++ {
			fmt.Printf(" ")
		}
		for j := 0; j <= i; j++ {
			if i == 0 {
				fmt.Printf("%d", j)
			} else {
				fmt.Printf("%d ", j)
			}
		}
		for j := i - 1; j >= 0; j-- {
			if j != 0 {
				fmt.Printf("%d ", j)
			} else {
				fmt.Printf("%d", j)
			}
		}
		fmt.Println()
	}
}

package main

import (
    "fmt"
)

func main() {
    var n int;
    fmt.Scan(&n)
    for j := 0; j < 2 * n; j++ {
        fmt.Printf(" ")
    }
    fmt.Printf("0\n")
    for i := 1; i <= n; i++ {
        for j := 0; j < 2 * (n - i); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j <= i; j++ {
            fmt.Print(j, " ")
        }
        for j := i-1; j > 0; j-- {
            fmt.Print(j, " ")
        }
        fmt.Printf("0\n")
    }
    for i := n + 1; i <= 2 * n; i++ {
        for j := 0; j < 2 * (i - n); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j < 2*n - i; j++ {
            fmt.Print(j, " ")
        }
        for j := 2*n - i; j > 0; j-- {
            fmt.Print(j, " ")
        }
        fmt.Printf("0\n")
    }
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var n int
    fmt.Scan(&n)
    for i := 0; i <= (n*2); i++ {
        var vi int
        if i <= n { vi = i } else { vi = (n*2)-i }
        for j := 0; j <= (n+vi); j++ {
            dist := vi-int(math.Abs(float64(j)-float64(n)))
            if dist < 0 { fmt.Print(" ") } else { fmt.Print(dist) }
            if j == (n+vi) { fmt.Println() } else { fmt.Print(" ") }
        }
    }
}

package main

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

func printPattern(writer *bufio.Writer, n int) {
	for i := 0; i <= n; i++ {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Fprint(writer, " ")
		}
		for j := 0; j <= i; j++ {
			if j == i && i == 0 {
				fmt.Fprintf(writer, "%d", j)
			} else {
				fmt.Fprintf(writer, "%d ", j)
			}
		}
		for j := i - 1; j >= 0; j-- {
			if j == 0 {
				fmt.Fprintf(writer, "%d", j)
			} else {
				fmt.Fprintf(writer, "%d ", j)
			}
		}
		fmt.Fprint(writer, "\n")
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Fprint(writer, " ")
		}
		for j := 0; j <= i; j++ {
			if j == i && i == 0 {
				fmt.Fprintf(writer, "%d", j)
			} else {
				fmt.Fprintf(writer, "%d ", j)
			}
		}
		for j := i - 1; j >= 0; j-- {
			if j == 0 {
				fmt.Fprintf(writer, "%d", j)
			} else {
				fmt.Fprintf(writer, "%d ", j)
			}
		}
		fmt.Fprint(writer, "\n")
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanln(reader, &n)
	printPattern(writer, n)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < 2*n+1; i++ {
		l := i
		if i > n {
			l = 2*n - i
		}

		for j := 0; j < 2*n+1; j++ {
			if j < n-l || j > n+l {
				if j < n-l {
					fmt.Print(" ")
				} else {
					continue
				}
			} else {
				k := l - dis(j, n)
				fmt.Print(l - dis(j, n))
				if j >= n && k == 0 {
					continue
				}
			}
			fmt.Print(" ")
		}
		fmt.Println("")
	}
}

func dis(x, y int) int {
	d := x - y
	if d < 0 {
		d = -1 * d
	}

	return d
}

package main
import (
    "fmt"
)
func main() {
    var n int
    fmt.Scan(&n)
    m :=0
    t:=0
    for r:=-n; r<=n; r++ {// 1 + 2n
        if r<0 {
            m=r*(-1)
        } else {m=r}
        t= n-m
        for j:=0;j<m;j++ {// 1 + 2n
            fmt.Printf("  ")
        }
        for i:=0;i<t;i++ {// 1 + 2n
            fmt.Printf("%d ",i)
        }
        for i:=t;i>0;i-- {//1 +2n
            fmt.Printf("%d ",i)
        }
        fmt.Println("0")
    }
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; i <= 2*n+1; i++ {
		t := i - 1
		if i > n+1 {
			t = n - (i - n) + 1
		}
		numspace := n - t
		for k := 0; k < numspace; k++ {
			fmt.Print("  ")
		}
		for j := 0; j < t; j++ {
			fmt.Print(j)
			fmt.Print(" ")
		}
		fmt.Print(t)
		for j := t - 1; j >= 0; j-- {
			fmt.Print(" ")
			fmt.Print(j)
		}
		fmt.Println("")
	}

}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

type pair struct {
	first  int
	second int
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	k := 0
	arrayStr := make([]string, 2*n+1)

	for i := 0; i <= n; i++ {
		arrayStr[k] = ""
		for j := 0; j < 2*(n-i); j++ {
			arrayStr[k] += " "
		}
		for j := 0; j <= i; j++ {
			arrayStr[k] += (strconv.Itoa(j) + " ")
		}
		for j := i - 1; j >= 0; j-- {
			arrayStr[k] += (strconv.Itoa(j) + " ")
		}
		arrayStr[k] = strings.TrimSuffix(arrayStr[k], " ")
		k++
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 2*(n-i); j++ {
			arrayStr[k] += " "
		}
		for j := 0; j <= i; j++ {
			arrayStr[k] += (strconv.Itoa(j) + " ")
		}
		for j := i - 1; j >= 0; j-- {
			arrayStr[k] += (strconv.Itoa(j) + " ")
		}
		arrayStr[k] = strings.TrimSuffix(arrayStr[k], " ")
		k++
	}
	for _, s := range arrayStr {
		fmt.Println(s)
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	_,er := fmt.Scan(&n)
	if er != nil {
		os.Exit(1)
	}
	for i := -n; i <= n; i++ {
		for j := 0; j < abs(i); j++ {
			fmt.Print("  ")
		}
		max_num := 3 - abs(i)
		for j := 0; j < 2*max_num; j++ {
			fmt.Printf("%d ", min(j,abs(2*max_num-j)))
		}
		fmt.Println("0")
	}
}

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

func min(num1 int, num2 int) int{
	if num1 < num2{
		return num1
	}else{
		return num2
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	_,er := fmt.Scan(&n)
	if er != nil {
		os.Exit(1)
	}
	for i := -n; i <= n; i++ {
		for j := 0; j < abs(i); j++ {
			fmt.Print("  ")
		}
		for j := 0; j < n-abs(i); j++ {
			fmt.Printf("%d ", j)
		}
		for j := n-abs(i); j>=0; j-- {
			fmt.Printf("%d ", j)
		}
		for j := 0; j < abs(i); j++ {
			fmt.Print("  ")
		}
		fmt.Println("")
	}
}

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

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	_,er := fmt.Scan(&n)
	if er != nil {
		os.Exit(1)
	}
	for i := -n; i <= n; i++ {
		for j := 0; j < abs(i); j++ {
			fmt.Print("  ")
		}
		for j := 0; j < n-abs(i); j++ {
			fmt.Printf("%d ", j)
		}
		for j := n-abs(i); j>=0; j-- {
			fmt.Printf("%d ", j)
		}
		fmt.Println("")
	}
}

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

package main
import (
	"fmt"
)
func main() {
	var n int
	fmt.Scan(&n)
	m :=0
	for r:=-n; r<=n; r++ {
		if r<0 {
			m=r*(-1)
		} else {m=r}
		t:= n-m
		for i:=0;i<m;i++ {
			fmt.Printf(" ")
		}
		for i:=0;i<t;i++ {
			fmt.Printf("%d ",i)
		}
		for i:=t;i>0;i-- {
			fmt.Printf("%d ",i)
		}
		fmt.Println("0")
	}
}

package main

import (
	"fmt"
)

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

	for t := 0; t < 2*n-1; t++ {
		var i int
		if t < n {
			i = t
		} else {
			i = 2*(n-1) - t
		}
		for j := i + 1; j < n*2-(i+1); j++ {
			fmt.Printf(" ")
		}
		for j := 0; j <= i; j++ {
			fmt.Printf("%d ", j)
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Printf("%d ", j)
		}
		fmt.Println()
	}
}

package main

import (
    "fmt"
)

func main() {
    var n int;
    fmt.Scan(&n)
    for i := 0; i <= n; i++ {
        for j := 0; j < 2 * (n - i); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j <= i; j++ {
            fmt.Print(" ", j)
        }
        for j := i-1; j >= 0; j-- {
            fmt.Print(" ", j)
        }
        fmt.Printf("\n")
    }
    for i := n + 1; i <= 2 * n; i++ {
        for j := 0; j < 2 * (i - n); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j < 2*n - i; j++ {
            fmt.Print(" ", j)
        }
        for j := 2*n - i; j >= 0; j-- {
            fmt.Print(" ", j)
        }
        fmt.Printf("\n")
    }
}

package main

import (
    "fmt"
)

func main() {
    var n int;
    fmt.Scan(&n)
    for i := 0; i <= n; i++ {
        for j := 0; j < 2 * (n - i); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j <= i; j++ {
            fmt.Print(j, " ")
        }
        for j := i-1; j >= 0; j-- {
            fmt.Print(j, " ")
        }
        fmt.Printf("\n")
    }
    for i := n + 1; i <= 2 * n; i++ {
        for j := 0; j < 2 * (i - n); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j < 2*n - i; j++ {
            fmt.Print(j, " ")
        }
        for j := 2*n - i; j >= 0; j-- {
            fmt.Print(j, " ")
        }
        fmt.Printf("\n")
    }
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var n int
    fmt.Scan(&n)
    for i := 0; i <= (n*2); i++ {
        var vi int
        if i <= n { vi = i } else { vi = (n*2)-i }
        for j := 0; j <= (n+i); j++ {
            dist := vi-int(math.Abs(float64(j)-float64(n)))
            if dist < 0 { fmt.Print(" ") } else { fmt.Print(dist) }
            if j == (n+i) { fmt.Println() } else { fmt.Print(" ") }
        }
    }
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var n int
    fmt.Scan(&n)
    for i := 0; i <= (n*2); i++ {
        var vi int
        if i <= n { vi = i } else { vi = (n*2)-i }
        for j := 0; j <= (n*2); j++ {
            dist := vi-int(math.Abs(float64(j)-float64(n)))
            if dist < 0 { fmt.Print(" ") } else { fmt.Print(dist) }
            if j == (n*2) { fmt.Println() } else { fmt.Print(" ") }
        }
    }
}

package main

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

func printPattern(writer *bufio.Writer, n int) {
	for i := 0; i <= n; i++ {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Fprint(writer, " ")
		}
		for j := 0; j <= i; j++ {
			fmt.Fprintf(writer, "%d ", j)
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Fprintf(writer, "%d ", j)
		}
		fmt.Fprint(writer, "\n")
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Fprint(writer, " ")
		}
		for j := 0; j <= i; j++ {
			fmt.Fprintf(writer, "%d ", j)
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Fprintf(writer, "%d ", j)
		}
		fmt.Fprint(writer, "\n")
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanln(reader, &n)
	printPattern(writer, n)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < 2*n+1; i++ {
		l := i
		if i > n {
			l = 2*n - i
		}

		for j := 0; j < 2*n+1; j++ {
			if j < n-l || j > n+l {
				if j < n-l {
					fmt.Print(" ")
				} else {
					continue
				}
			} else {
				k := l - dis(j, n)
				fmt.Print(l - dis(j, n))
				if j > n && k == 0 {
					continue
				}
			}
			fmt.Print(" ")
		}
		fmt.Println("")
	}
}

func dis(x, y int) int {
	d := x - y
	if d < 0 {
		d = -1 * d
	}

	return d
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < 2*n+1; i++ {
		l := i
		if i > n {
			l = 2*n - i
		}

		for j := 0; j < 2*n+1; j++ {
			if j < n-l || j > n+l {
				if j < n-l {
					fmt.Print(" ")
				}
			} else {
				k := l - dis(j, n)
				fmt.Print(l - dis(j, n))
				if j > n && k == 0 {
					continue
				}
			}
			fmt.Print(" ")
		}
		fmt.Println("")
	}
}

func dis(x, y int) int {
	d := x - y
	if d < 0 {
		d = -1 * d
	}

	return d
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < 2*n+1; i++ {
		l := i
		if i > n {
			l = 2*n - i
		}

		for j := 0; j < 2*n+1; j++ {
			if j < n-l || j > n+l {
				fmt.Print(" ")
			} else {
				fmt.Print(l - dis(j, n))
			}
			fmt.Print(" ")
		}
		fmt.Println("")
	}
}

func dis(x, y int) int {
	d := x - y
	if d < 0 {
		d = -1 * d
	}

	return d
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; i <= 2*n+1; i++ {
		t := i - 1
		if i > n+1 {
			t = n - (i - n)
		}
		numspace := n - t
		for k := 0; k < numspace; k++ {
			fmt.Print("  ")
		}
		for j := 0; j < t; j++ {
			fmt.Print(j)
			fmt.Print(" ")
		}
		fmt.Print(t)
		for j := t - 1; j >= 0; j-- {
			fmt.Print(" ")
			fmt.Print(j)
		}
		fmt.Println("")
	}

}

package main

import (
	"fmt"
)

type pair struct {
	first  int
	second int
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i <= n; i++ {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Print(" ")
		}
		for j := 0; j <= i; j++ {
			fmt.Print(j, " ")
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Print(j, " ")
		}
		fmt.Println("\b")
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Print(" ")
		}
		for j := 0; j <= i; j++ {
			fmt.Print(j, " ")
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Print(j, " ")
		}
		fmt.Println("\b")
	}
}

package main

import (
	"fmt"
)

type pair struct {
	first  int
	second int
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i <= n; i++ {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Print(" ")
		}
		for j := 0; j <= i; j++ {
			fmt.Print(j, " ")
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Print(j, " ")
		}
		fmt.Println("")
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Print(" ")
		}
		for j := 0; j <= i; j++ {
			fmt.Print(j, " ")
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Print(j, " ")
		}
		fmt.Println("")
	}
}


You are given $$$n$$$ strings $$$s_1, s_2, \ldots, s_n$$$ consisting of lowercase Latin letters.In one operation you can remove a character from a string $$$s_i$$$ and insert it to an arbitrary position in a string $$$s_j$$$ ($$$j$$$ may be equal to $$$i$$$). You may perform this operation any number of times. Is it possible to make all $$$n$$$ strings equal?

The first line contains $$$t$$$ ($$$1 \le t \le 10$$$): the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of strings. $$$n$$$ lines follow, the $$$i$$$-th line contains $$$s_i$$$ ($$$1 \le \lvert s_i \rvert \le 1000$$$). The sum of lengths of all strings in all test cases does not exceed $$$1000$$$.

If it is possible to make the strings equal, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can output each character in either lowercase or uppercase.

4
2
caa
cbb
3
cba
cba
cbb
4
ccab
cbac
bca
acbcc
4
acb
caf
c
cbafc

NoteIn the first test case, you can do the following:   Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively. Remove the second character of the second string and insert it after the second character of the first string, making both strings equal to "cab". In the second test case, it is impossible to make all $$$n$$$ strings equal.

package main

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

var str [1005]string

func main()  {
	t:=ReadInt()
	for i:=0;i<t;i++{
		n:=ReadInt()
		var bit [26]int
		for j:=0;j<n;j++{
			str[i]=ReadString()
			for _,val:= range str[i]{
				bit[val-'a']++
			}
		}
		f:=true
		for j:=0;j<26;j++{
			if(bit[j]%n!=0){
				fmt.Println("NO")
				f=false
				break
			}
		}
		if(f){
			fmt.Println("YES")
		}
	}
	close(out)
}
var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup
func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _  := strconv.Atoi(intStr)
	return i
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

		for line := range out {
			write.WriteString(line + "\n")
		}
	}(writer)
}

package main

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

func main() {
	var t, n int
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		count := make(map[string]int, 0)
		fmt.Fscan(in, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &s)
			for _, v := range s {
				count[string(v)]++
			}
		}
		ans := "YES"
		for _, v := range count {
			if v%n != 0 {
				ans = "NO"
				break
			}
		}
		fmt.Println(ans)
	}

}

package main

import (
    "fmt"
)

func solve() {
    var n int
    var s string

    fmt.Scan(&n)
    dict := make(map[byte]int, 26)

    for i := 0; i < n; i++ {
        fmt.Scan(&s)
        for j := 0; j < len(s); j++ {
            _, ok := dict[s[j]]
            if !ok {
                dict[s[j]] = 1
            } else {
                dict[s[j]] += 1
            }
        }
    }

    for _, v := range dict {
        if v % n != 0 {
            fmt.Println("NO")
            return
        }
    }

    fmt.Println("YES")
}

func main() {
    var t int

    fmt.Scan(&t)

    for i := 0; i < t; i++ {
        solve()
    }
}

package main

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

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

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

	ins := func() string {
		sc.Scan()
		return sc.Text()
	}

	for t := in(); t > 0; t-- {
		n := in()

		a := make([]string, n)

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

		m := make(map[byte]int)

		for i := range a {
			for j := range a[i] {
				m[a[i][j]]++
			}
		}

		ok := true

		for _, v := range m {
			if v%n != 0 {
				ok = false
				break
			}
		}

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

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 letterCounts map[rune]int

func addLetter(r rune) {
	if count, ok := letterCounts[r]; ok {
		letterCounts[r] = count + 1
	} else {
		letterCounts[r] = 1
	}
}

func main() {
	defer writer.Flush()

	var t, n int
	var str string

	scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		letterCounts = make(map[rune]int)

		scanf("%d\n", &n)
		for j := 0; j < n; j++ {
			scanf("%s\n", &str)

			for _, r := range str {
				addLetter(r)
			}
		}

		equal := true
		for _, count := range letterCounts {
			if count%n != 0 {
				equal = false
				break
			}
		}

		if equal {
			printf("YES")
		} else {
			printf("NO")
		}
		printf("\n")
	}
}

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

package main

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

var (
	t int

	n int
	S [][]rune
)

func main() {
	t = readi()
	for tc := 0; tc < t; tc++ {
		n = readi()
		S = [][]rune{}
		for i := 0; i < n; i++ {
			row := readrs()
			S = append(S, row)
		}
		// for _, R := range S {
		// 	PrintfDebug("%s\n", string(R))
		// }
		// PrintfDebug("\n")

		solve()
	}
}

func solve() {
	cnts := [30]int{}

	for i := 0; i < n; i++ {
		R := S[i]
		for _, c := range R {
			cnts[c-'a']++
		}
	}

	for i := 'a'; i <= 'z'; i++ {
		if cnts[i-'a']%n != 0 {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}

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

/********** common constants **********/

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

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

// modint can calculate a right residual whether value is positive or negative.
func modint(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// modll can calculate a right residual whether value is positive or negative.
func modll(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

/********** bufio setting **********/

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

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

/*********** Input ***********/

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

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

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

package main

import "fmt"

func main(){

	nCase := 0

	_,err := fmt.Scanf("%d\n", &nCase)
	if err != nil {
		return
	}

	for i:=0;i<nCase;i++{
		line := 0
		_, err := fmt.Scanf("%d\n", &line)
		if err != nil {
			return
		}
		ss := []string{}
		for j:=0;j<line;j++{
			s := ""
			_, err := fmt.Scanf("%s\n", &s)
			if err != nil {
				return
			}
			ss = append(ss, s)
		}
		if judge(line, ss){
			fmt.Printf("YES\n")
		}else{
			fmt.Printf("NO\n")
		}
	}
}

func judge(line int, ss []string)bool{
	if line <= 0 || len(ss) == 0{
		return false
	}

	m := map[string]int{}   //记录字母的次数
	for _,s := range(ss){
		for _,c := range(s){
			m[string(c)]++
		}
	}

	//如果不能被整除的话，说明不符合要求
	for _,v := range(m){
		if v%line != 0{
			return false
		}
	}

	return true
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scanf("%d\n", &n)
	s := make([]string, n)
	cnt := make([]int, 26)

	for i := range s {
		fmt.Scanf("%s\n", &s[i])
		for _, c := range s[i] {
			cnt[c - 'a']++
		}
	}
	for _, v := range cnt {
		if v % n != 0 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for t > 0 {
		solve()
		t--
	}
}

package main

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

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

	scanString := func(s *string) {
		scanner.Scan()
		text := scanner.Text()
		*s = text
	}

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

	var n, w int
	var s string
	scanInt(&n) // number of cases

	for i := 0; i < n; i++ {
		scanInt(&w) // number of word
		chars := map[int32]int{}
		for j := 0; j < w; j++ {
			scanString(&s)
			for _, char := range s {
				if _, ok := chars[char]; ok {
					chars[char]++
				} else {
					chars[char] = 1
				}
			}
		}
		match := true
		for _, count := range chars {
			if count % w != 0 {
				match = false
			}
		}
		if match {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

const ERROR_EXIT int = -1

func main(){

	nCase := 0

	_,err := fmt.Scanf("%d", &nCase)
	if err != nil {
		return
	}

	for i:=0;i<nCase;i++{
		line := 0
		_, err := fmt.Scanf("%d", &line)
		if err != nil {
			return
		}
		ss := []string{}
		for j:=0;j<line;j++{
			s := ""
			_, err := fmt.Scanf("%s", &s)
			if err != nil {
				return
			}
			ss = append(ss, s)
		}
		if judge(line, ss){
			fmt.Printf("YES\n")
		}else{
			fmt.Printf("NO\n")
		}
	}
}

func judge(line int, ss []string)bool{
	if line <= 0 || len(ss) == 0{
		return false
	}

	m := map[string]int{}   //记录字母的次数
	for _,s := range(ss){
		for _,c := range(s){
			m[string(c)]++
		}
	}

	//如果不能被整除的话，说明不符合要求
	for _,v := range(m){
		if v%line != 0{
			return false
		}
	}

	return true
}


You're given an integer $$$n$$$. For every integer $$$i$$$ from $$$2$$$ to $$$n$$$, assign a positive integer $$$a_i$$$ such that the following conditions hold:  For any pair of integers $$$(i,j)$$$, if $$$i$$$ and $$$j$$$ are coprime, $$$a_i \neq a_j$$$.  The maximal value of all $$$a_i$$$ should be minimized (that is, as small as possible). A pair of integers is called coprime if their greatest common divisor is $$$1$$$.

The only line contains the integer $$$n$$$ ($$$2 \le n \le 10^5$$$).

Print $$$n-1$$$ integers, $$$a_2$$$, $$$a_3$$$, $$$\ldots$$$, $$$a_n$$$ ($$$1 \leq a_i \leq n$$$).  If there are multiple solutions, print any of them.

NoteIn the first example, notice that $$$3$$$ and $$$4$$$ are coprime, so $$$a_3 \neq a_4$$$. Also, notice that $$$a=[1,2,3]$$$ satisfies the first condition, but it's not a correct answer because its maximal value is $$$3$$$.

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n+1)
	x := 1
	for i := 2; i <= n; i++ {
		if a[i] == 0 {
			a[i] = x
			x++
		}
		for j := i * 2; j <= n; j += i {
			if a[j] == 0 {
				a[j] = a[i]
			}
		}
	}
	for i := 2; i <= n-1; i++ {
		fmt.Printf("%v ", a[i])
	}
	fmt.Printf("%v\n", a[n])
}

package main

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

const (
	mod = uint64(1e9 + 7)
)

func isPrime(q int) int {
	if q < 3 {
		return -1
	}
	for i := 2; i*i <= q; i++ {
		if q%i == 0 {
			return i
		}
	}
	return -1
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n+1)
	cur := 0
	for i := 2; i <= n; i++ {
		tmp := isPrime(i)
		if tmp == -1 {
			cur++
			a[i] = cur
		} else {
			a[i] = a[tmp]
		}
	}
	for i := 2; i <= n-1; i++ {
		fmt.Fprintf(out, "%d ", a[i])
	}
	fmt.Fprintf(out, "%d\n", a[n])
	return
}

// find num of elem >= k
func find(a []int, k int) int {
	if len(a) == 0 {
		return 0
	}
	n := len(a)
	if a[0] > k {
		return n
	}
	if a[n-1] < k {
		return 0
	}
	l := 0
	r := len(a) - 1
	for l < r {
		mid := (l + r) / 2
		if a[mid] < k {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return n - l
}

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

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

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

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

func ok(a, b int) bool {
	if min(abs(a-b), abs(a+b)) <= min(abs(a), abs(b)) && max(abs(a+b), abs(a-b)) >= max(abs(a), abs(b)) {
		return true
	}
	return false
}

package main

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

var DEBUG = true

func main() {
	defer Flush()

	N := readi()
	a := make([]int, N+1)

	for i := 2; i < len(a); i += 2 {
		a[i] = 1
	}
	v := 2
	for k := 3; k < len(a); k += 2 {
		i := k
		if a[i] != 0 {
			continue
		}
		for ; i < len(a); i += k {
			a[i] = v
		}
		v++
	}
	sp := ""
	for i := 2; i < len(a); i++ {
		printf("%s%d", sp, a[i])
		sp = " "
	}
	println()

}

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

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

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

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

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

// Author: sighduck
// URL: https://codeforces.com/contest/1174/problem/C

package main

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

func Solve(n int) []int {
	a := make([]int, n+1)
	color := 1
	squareRoot := int(math.Sqrt(float64(n))) + 1
	for i := 2; i <= squareRoot; i++ {
		if a[i] == 0 {
			a[i] = color
			for j := i * i; j <= n; j += i {
				a[j] = color
			}
			color += 1
		}
	}
	for i := 2; i <= n; i++ {
		if a[i] == 0 {
			a[i] = color
			color += 1
		}
	}
	return a[2:]
}

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

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

	a := Solve(n)
	for _, elem := range a {
		fmt.Fprintf(writer, "%d ", elem)
	}
	fmt.Fprintf(writer, "\n")
}