Hemose was shopping with his friends Samez, AhmedZ, AshrafEzz, TheSawan and O_E in Germany. As you know, Hemose and his friends are problem solvers, so they are very clever. Therefore, they will go to all discount markets in Germany.

Hemose has an array of $n$ integers. He wants Samez to sort the array in the non-decreasing order. Since it would be a too easy problem for Samez, Hemose allows Samez to use only the following operation:

Choose indices $i$ and $j$ such that $1 \le i, j \le n$, and $\lvert i - j \rvert \geq x$. Then, swap elements $a_i$ and $a_j$.

Can you tell Samez if there's a way to sort the array in the non-decreasing order by using the operation written above some finite number of times (possibly $0$)?


-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ $(1 \leq t \leq 10^5)$. Description of the test cases follows.

The first line of each test case contains two integers $n$ and $x$ $(1 \leq x \leq n \leq 10^5)$.

The second line of each test case contains $n$ integers $a_1, a_2, ..., a_n$ $(1 \leq a_i \leq 10^9)$.

It is guaranteed that the sum of $n$ over all test cases doesn't exceed $2 \cdot 10^5$.


-----Output-----

For each test case, you should output a single string.

If Samez can sort the array in non-decreasing order using the operation written above, output "YES" (without quotes). Otherwise, output "NO" (without quotes).

You can print each letter of "YES" and "NO" in any case (upper or lower).


-----Examples-----

Input
4
3 3
3 2 1
4 3
1 2 3 4
5 2
5 1 2 3 4
5 4
1 2 3 4 4
Output
NO
YES
YES
YES


-----Note-----

In the first test case, you can't do any operations.

In the second test case, the array is already sorted.

In the third test case, you can do the operations as follows:

$[5,1,2,3,4]$, $swap(a_1,a_3)$

$[2,1,5,3,4]$, $swap(a_2,a_5)$

$[2,4,5,3,1]$, $swap(a_2,a_4)$

$[2,3,5,4,1]$, $swap(a_1,a_5)$

$[1,3,5,4,2]$, $swap(a_2,a_5)$

$[1,2,5,4,3]$, $swap(a_3,a_5)$

$[1,2,3,4,5]$

(Here $swap(a_i, a_j)$ refers to swapping elements at positions $i$, $j$).

Difficulty: EASY
Tags: Spanning trees

Sorting

Mathematics

Constructive algorithms
Skill types: Sorting

Starter code:

Solutions:
import sys
input = lambda : sys.stdin.readline()[:-1]
ni = lambda : int(input())
na = lambda : list(map(int, input().split()))
sys.setrecursionlimit(10 ** 7)
yes = lambda : print('yes')
Yes = lambda : print('Yes')
YES = lambda : print('YES')
no = lambda : print('no')
No = lambda : print('No')
NO = lambda : print('NO')

def f(a):
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			return False
	return True
t = ni()
for _ in range(t):
	(n, x) = na()
	a = na()
	if x * 2 <= n:
		YES()
		continue
	else:
		x = n - x
		if x == 0:
			if f(a):
				YES()
			else:
				NO()
			continue
		b = a[:x] + a[-x:]
		b = sorted(b)
		ans = 1
		if b[x - 1] > a[x]:
			ans = 0
		if b[x] < a[n - x - 1]:
			ans = 0
		for i in range(x, n - x - 1):
			if a[i] > a[i + 1]:
				ans = 0
		if ans:
			YES()
		else:
			NO()


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
inf = 10 ** 16
md = 998244353

def solve():
	(n, x) = LI()
	aa = LI()
	l = n - x
	r = x
	if l >= r:
		print('YES')
		return
	bb = aa[:l] + aa[r:]
	bb.sort()
	aa = bb[:l] + aa[l:r] + bb[l:]
	for i in range(n - 1):
		if aa[i] > aa[i + 1]:
			print('NO')
			return
	print('YES')
for testcase in range(II()):
	solve()


from sys import stdin

def read_input():
	(n, x) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	return (n, x, a)

def solve(n, x, a):
	b = a[:]
	b.sort()
	for i in range(n - x, x):
		if a[i] != b[i]:
			return 'NO'
	return 'YES'

def main():
	t = int(stdin.readline())
	for _ in range(t):
		input = read_input()
		answer = solve(*input)
		print(answer)
main()


from sys import stdin

def solve():
	results = []
	for _ in range(int(stdin.readline().strip())):
		(N, X) = map(int, stdin.readline().strip().split())
		A = list(map(int, stdin.readline().strip().split()))
		sortedA = sorted(A)
		if A == sortedA:
			results.append('YES')
			continue
		if N <= X:
			results.append('NO')
			continue
		if X <= N // 2:
			results.append('YES')
			continue
		if A[N - X:X] == sortedA[N - X:X]:
			results.append('YES')
		else:
			results.append('NO')
	print('\n'.join(map(str, results)))
solve()


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, x) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	b = sorted(a)
	end = x
	start = n - x
	res = 'YES'
	for i in range(start, end):
		if a[i] != b[i]:
			res = 'NO'
			break
	print(res)


import random
import sys

def input():
	return sys.stdin.readline().strip('\n')

def cin_int_ls():
	return list(map(int, input().split()))

def cin_int():
	return int(input())
import random

def bf(ls, k):
	memo = set()
	psb = [ls]
	memo.add(tuple(ls))
	for _ in range(1000):
		l = random.randint(0, len(ls) - k)
		r = l + random.randint(k, len(ls))
		if r < len(ls):
			for i in psb:
				(i[l], i[r]) = (i[r], i[l])
				memo.add(tuple(i))
	for i in sorted(list(memo)):
		print(i)

def sv(ls, x):
	if len(ls) >= 2 * x:
		return True
	ols = sorted(ls)
	rg = len(ls) - x
	n = len(ls)
	memo = set(ols[:rg] + ols[n - rg:])
	for i in range(len(ls) // 2 + 1):
		if i < rg and ls[i] in memo and (ls[-i - 1] in memo):
			continue
		elif i >= rg and ls[i] == ols[i] and (ls[-i - 1] == ols[-i - 1]):
			continue
		else:
			return False
	return True

def main():
	for _ in range(cin_int()):
		(n, x) = cin_int_ls()
		ls = cin_int_ls()
		if sv(ls, x):
			print('YES')
		else:
			print('NO')
main()


import sys
import math
from bisect import bisect_right as br
from itertools import combinations as cb

def int_arr():
	return list(map(int, sys.stdin.readline().strip().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, x) = int_arr()
	arr = int_arr()
	temp = arr.copy()
	temp.sort()
	if x <= n // 2 or arr == temp:
		print('YES')
		continue
	ul = x
	ll = n - x + 1
	sub = arr[ll - 1:ul]
	sub2 = temp[ll - 1:ul]
	if sub == sub2:
		print('YES')
	else:
		print('NO')


for step in range(int(input())):
	(n, x) = map(int, input().split())
	nums = list(map(int, input().split()))
	is_yes = False
	if n // 2 >= x:
		is_yes = True
	elif nums[n - x:x] == sorted(nums)[n - x:x]:
		is_yes = True
	print('YES' if is_yes else 'NO')


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
mod = 10 ** 9 + 7
ANS = []
input = stdin.readline

def solve():
	pass
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	if n >= 2 * x:
		print('YES')
		continue
	else:
		temp = arr[:]
		temp.sort()
		f = 1
		for i in range(n - x, x):
			if temp[i] != arr[i]:
				f = 0
		print('YES' if f == 1 else 'NO')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 'YES'
	b = a.copy()
	b.sort()
	if n >= 2 * x:
		print(ans)
	else:
		for i in range(n - x, x):
			if a[i] != b[i]:
				ans = 'NO'
		print(ans)


for _ in range(int(input())):
	(n, h) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = sorted(arr)
	flag = 1
	for i in range(n - h, h):
		if ans[i] != arr[i]:
			flag = 0
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


games = int(input())
res = []
while games != 0:
	nn = input()
	nnn = list(nn.split(' '))
	n = int(nnn[0])
	x = int(nnn[1])
	chisla = input()
	m = [int(t) for t in chisla.split(' ')]
	m2 = []
	for z in m:
		m2.append(z)
	m2.sort()
	if x <= int(n / 2):
		res.append('YES')
		games -= 1
		continue
	if x > int(n / 2):
		new_m2 = m2[n - x:x]
		new_m = m[n - x:x]
		if new_m == new_m2:
			res.append('YES')
			games -= 1
			continue
		else:
			res.append('NO')
			games -= 1
			continue
	games -= 1
for x in res:
	print(x)


for __ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if n >= 2 * x:
		print('YES')
		continue
	b = sorted(a)
	if a[n - x:x] == b[n - x:x]:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = list(map(int, input().split()))
	if b >= len(x):
		if x == sorted(x):
			print('YES')
		else:
			print('NO')
	elif a - b > b - 1:
		print('YES')
	else:
		c = sorted(x)
		if x[a - b:b] == c[a - b:b]:
			print('YES')
		else:
			print('NO')


from sys import stdin

def test():
	line = stdin.readline().split()
	(n, k) = (int(_) for _ in line)
	a = [int(_) for _ in stdin.readline().split()]
	l = max(0, n - k)
	r = min(n, k)
	p = a[0:l] + a[r:n]
	p.sort()
	b = p[0:l] + a[l:r] + p[l:2 * l]
	for i in range(0, n - 1):
		if b[i + 1] < b[i]:
			return False
	return True
tk = int(stdin.readline())
for i in range(0, tk):
	if test():
		print('YES')
	else:
		print('NO')


from math import ceil, gcd
from math import factorial as fact, comb as ncr
from math import sqrt
from bisect import bisect_left as bl
from bisect import bisect_right as br
from array import array
from collections import Counter as ctr
from collections import deque as dq

def li():
	return list(map(int, input().split()))

def arr(a):
	return array('i', a)

def solve():
	for _ in range(int(input())):
		(n, x) = li()
		a = li()
		b = sorted(a)
		if a == b:
			print('YES')
		elif x >= n:
			print('NO')
		elif n >= x * 2:
			print('YES')
		else:
			lm = n - x
			ul = x
			f = True
			for i in range(n - x, x):
				if a[i] != b[i]:
					f = False
					print('NO')
					break
			if f:
				print('YES')
solve()


Input = '\n5\n3 3\n3 2 1\n4 3\n1 2 3 4\n5 2\n5 1 2 3 4\n5 4\n1 2 3 4 4\n3 2\n2 3 1\n'[1:-1].split('\n')
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	A = sorted(a)
	if a == A:
		print('YES')
	elif x >= n:
		print('NO')
	else:
		N = n - (n - x) * 2
		if N <= 0:
			print('YES')
		else:
			P = n - x
			print('YES' if a[P:P + N] == A[P:P + N] else 'NO')


def solve(xs, n, k):
	sorted_xs = sorted(xs)
	if xs == sorted_xs:
		return True
	if k < n // 2:
		return True
	(left, right) = (n - k, k)
	if sorted_xs[left:right] != xs[left:right]:
		return False
	return True

def main():
	for _ in range(int(input())):
		(n, x) = [int(x) for x in input().split()]
		xs = [int(x) for x in input().split()]
		ans = 'YES' if solve(xs, n, x) else 'NO'
		print(ans)
main()


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	s = list(map(int, input().split()))
	if x <= n // 2:
		print('YES')
	else:
		u = s[:]
		s.sort()
		k = 2 * (x - n // 2) - n % 2
		for j in range((n - k) // 2, (n - k) // 2 + k):
			if s[j] != u[j]:
				print('NO')
				break
		else:
			print('YES')


case = int(input())
for i in range(case):
	(n, x) = (int(v) for v in input().split())
	list1 = [int(u) for u in input().split()]
	if n == 1:
		print('YES')
	elif n - x < 1:
		for m in range(n):
			if m == n - 1:
				print('YES')
			elif list1[m + 1] < list1[m]:
				print('NO')
				break
	elif 2 * x <= n:
		print('YES')
	else:
		lr = []
		middle = []
		left = n - x
		for j in range(n):
			if j < left or j > n - left - 1:
				lr.append(list1[j])
			else:
				middle.append(list1[j])
		for k in range(len(middle)):
			if k == len(middle) - 1:
				lr.sort()
				if middle[0] < lr[len(lr) // 2 - 1] or middle[len(middle) - 1] > lr[len(lr) // 2]:
					print('NO')
				else:
					print('YES')
			elif middle[k + 1] < middle[k]:
				print('NO')
				break


from collections import deque, Counter, defaultdict
import math
import heapq
T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	a = sorted(arr)
	if arr == a:
		print('YES')
	elif n - 1 < x:
		print('NO')
	else:
		l1 = 0
		l2 = l1 + x
		r2 = n - 1
		r1 = r2 - x
		ans = False
		if l2 - r1 > 1:
			for i in range(r1 + 1, l2):
				if a[i] != arr[i]:
					print('NO')
					ans = True
					break
			if ans == False:
				print('YES')
		else:
			print('YES')


def can_sort(aa, x):
	n = len(aa)
	if all((aa[i] <= aa[i + 1] for i in range(n - 1))):
		return True
	if x <= 1:
		return True
	if x >= n:
		return False
	if x <= n - x - 1 + 1:
		return True
	aa_sorted = sorted(aa)
	if all((aa[i] == aa_sorted[i] for i in range(n - x - 1 + 1, x))):
		return True
	return False
n_t = int(input())
for t in range(n_t):
	(n, x) = map(int, input().split(' '))
	aa = list(map(int, input().split(' ')))
	assert len(aa) == n
	result = can_sort(aa, x)
	print('YES' if result else 'NO')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	(*arr,) = map(int, input().split())
	arr2 = arr[:]
	arr2.sort()
	ok = 'YES'
	for i in range(n):
		if arr[i] != arr2[i] and i - x < 0 and (i + x >= n):
			ok = 'NO'
			break
	print(ok)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = []
	l1 = l.copy()
	l1.sort()
	if l == l1:
		print('YES')
	elif k <= n // 2:
		print('YES')
	elif k > n // 2:
		c = 0
		for i in range(n - k, k):
			if l[i] != l1[i]:
				c = -1
				break
		if c == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	check = False
	for i in range(n):
		if i - x < 0 and i + x >= n and (a[i] != b[i]):
			check = True
			break
	if check:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if n == 1 or x <= n // 2 or a == sorted(a):
		print('YES')
	else:
		b = sorted(a)
		no = False
		for j in range(n - x, x):
			if a[j] != b[j]:
				print('NO')
				no = True
				break
		if not no:
			print('YES')


def result(x, array_list, length):
	if length >= 2 * x:
		print('YES')
	else:
		bc = array_list.copy()
		bc.sort()
		if bc[length - x:x] == array_list[length - x:x]:
			print('YES')
		else:
			print('NO')
for i in range(int(input())):
	ab = list(map(int, input().split()))
	bc = list(map(int, input().split()))
	result(ab[1], bc, ab[0])


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if a == sorted(a):
		print('YES')
	elif n >= 2 * x:
		print('YES')
	else:
		flag = True
		b = a.copy()
		b.sort()
		for j in range(n - x, x):
			if a[j] != b[j]:
				flag = False
				break
		if flag == False:
			print('NO')
		else:
			print('YES')


import sys
input = sys.stdin.readline

def solve():
	(n, x) = map(int, input().split())
	(*a,) = map(int, input().split())
	s = None
	m = []
	b = []
	for i in range(n):
		if i - x < 0 and i + x >= n:
			if s is None:
				s = i
			m.append(a[i])
		else:
			b.append(a[i])
	if s is None:
		print('YES')
	else:
		b.sort()
		c = b[:s] + m + b[s:]
		a.sort()
		if c == a:
			print('YES')
		else:
			print('NO')
for i in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = sorted(a)
	if a == s:
		print('YES')
	elif 2 * x > n - 1:
		if s[n - x:x] == a[n - x:x]:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


def f():
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	m = sorted(l)
	for i in range(n):
		if i - x < 0 and i + x >= n:
			if l[i] != m[i]:
				return 'NO'
	return 'YES'
for _ in range(int(input())):
	print(f())


def solve():
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	sarr = sorted(arr)
	flag = 0
	for i in range(n):
		if sarr[i] != arr[i]:
			if n - i - 1 >= x or i >= x:
				continue
			else:
				print('NO')
				return
	print('YES')
t = int(input())
for i in range(t):
	solve()


for i in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = sorted(arr)
	a = n - x
	b = x - 1
	for i in range(a, b + 1):
		if arr[i] != brr[i]:
			print('NO')
			break
	else:
		print('YES')


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = sorted(l)
	ans = 'YES'
	for i in range(x):
		if i + x < n:
			continue
		elif l[i] != s[i]:
			ans = 'NO'
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	n_a = list(map(int, input().split()))
	a_s = sorted(n_a)
	bad = 0
	for i in range(n - x, x):
		if a_s[i] != n_a[i]:
			bad = 1
			break
	if bad:
		print('NO')
	else:
		print('YES')


from random import *
from math import *
T = int(input())
for t in range(T):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	if x >= n:
		if A == sorted(A):
			print('YES')
		else:
			print('NO')
		continue
	main = set()
	for i in range(x, n):
		main.add(i)
	for i in range(n - 1 - x, -1, -1):
		main.add(i)
	if len(main) == len(A):
		print('YES')
		continue
	cur = []
	for i in range(n):
		if i not in main:
			cur.append(A[i])
	if cur != sorted(cur):
		print('NO')
	else:
		all = []
		for i in main:
			all.append(A[i])
		all.sort()
		if all[len(all) // 2 - 1] > cur[0] or all[len(all) // 2] < cur[-1]:
			print('NO')
		else:
			print('YES')


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	if x <= n // 2:
		print('YES')
	else:
		y = 0
		for i in range(n - x, x):
			if a[i] != b[i]:
				y = 1
				break
		if y == 0:
			print('YES')
		else:
			print('NO')


def hemose_shopping(a, x, n):
	if 2 * x < n:
		return 'YES'
	a_ = sorted(a)
	for i in range(1, n + 1):
		if a[i - 1] != a_[i - 1]:
			if i - x < 1:
				if i + x > n:
					return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	print(hemose_shopping(a, x, n))


def main():
	t = int(input())
	if t == 20000:
		print('BRUHHH')
	for _ in range(t):
		(n, x) = map(int, input().split())
		arr = list(map(int, input().split()))
		a = arr.copy()
		a.sort()
		f = True
		for i in range(n):
			d1 = i
			d2 = n - 1 - i
			if arr[i] != a[i] and d1 < x and (d2 < x):
				print('NO')
				f = False
				break
		if f:
			print('YES')
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	if b == a or x <= n // 2:
		print('YES')
	elif x >= n:
		print('NO')
	else:
		z = 0
		for i in range(n - x, x):
			if a[i] != b[i]:
				z = -1
				break
		if z == 0:
			print('YES')
		else:
			print('NO')


for fgbhjm in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if x <= n // 2 + n % 2 - 1:
		print('YES')
	else:
		s = sorted(a)
		ans = True
		dif = x - n // 2 + n % 2 - 1
		for i in range(n):
			if i - 0 < x and n - i - 1 < x and (a[i] != s[i]):
				ans = False
				break
		if ans:
			print('YES')
		else:
			print('NO')


def fun(arr, n, x):
	brr = arr.copy()
	brr.sort()
	if arr == brr:
		return 'YES'
	if x <= n // 2:
		return 'YES'
	else:
		if n == x:
			return 'NO'
		for i in range(n - x, x):
			if arr[i] != brr[i]:
				return 'NO'
		return 'YES'
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	print(fun(arr, n, x))


def fun(ls, lt):
	st = sorted(ls)
	(n, x) = lt
	if x <= n // 2:
		print('YES')
		return
	last_index = min(x, n)
	for i in range(0, last_index):
		if i + x <= n - 1:
			continue
		elif st[i] != ls[i]:
			print('NO')
			return
	print('YES')
T = int(input())
for i in range(T):
	lt = list(map(int, input().split()))
	ls = list(map(int, input().split()))
	fun(ls, lt)


t = int(input())
for x in range(t):
	b = [int(y) for y in input().split()]
	n = b[0]
	x = b[1]
	a = [int(y) for y in input().split()]
	if n >= 2 * x:
		print('YES')
	else:
		c = []
		for z in range(n):
			c.append(a[z])
		c.sort()
		for z in range(n - x, x):
			if a[z] != c[z]:
				ans = -1
				break
			else:
				ans = 0
		if ans == 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	if x <= n // 2:
		print('YES')
	else:
		f = 0
		t = l[:]
		t.sort()
		for i in range(n):
			if t[i] != l[i]:
				f = 1
		if f == 0:
			print('YES')
			continue
		f = 0
		for i in range(n - x, x):
			if l[i] != t[i]:
				f = 1
		if f == 1:
			print('NO')
		else:
			print('YES')


T = int(input())
for t in range(T):
	(n, x) = [int(k) for k in input().split(' ')]
	a = [int(k) for k in input().split(' ')]
	sorted_a = sorted(a)
	middle = a[n - x:x]
	middle_sorted = sorted_a[n - x:x]
	if middle == middle_sorted:
		print('YES')
	else:
		print('NO')


t = int(input())
for o in range(0, t, 1):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if n >= 2 * k:
		print('YES')
	else:
		c = 0
		a = sorted(l)
		for j in range(n - k, k, 1):
			if a[j] != l[j]:
				c = c + 1
				break
		if c == 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	li = list(map(int, input().split()))
	res = li.copy()
	res.sort()
	if res == li:
		print('YES')
	else:
		f = 0
		for i in range(n):
			if li[i] != res[i]:
				if i + x < n or i - x >= 0:
					True
				else:
					f = 1
		if f == 1:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	j = sorted(l)
	if l == j:
		print('YES')
	elif b >= a:
		print('NO')
	elif b <= a // 2:
		print('YES')
	elif a % 2 == 1:
		if l[a - b:b] == j[a - b:b]:
			print('YES')
		else:
			print('NO')
	elif l[a - b:b] == j[a - b:b]:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	for i in range(n):
		b.append(a[i])
	b.sort()
	val = n - x
	if val >= math.ceil(n / 2):
		print('YES')
		continue
	flag = 0
	for i in range(val, n - val):
		if a[i] != b[i]:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	tarr = sorted(arr)
	if arr == tarr:
		print('YES')
	else:
		lind = n - 1 - x + 1
		rind = x - 1
		if lind > rind:
			print('YES')
		elif tarr[lind:rind + 1] == arr[lind:rind + 1]:
			print('YES')
		else:
			print('NO')


import sys
input = sys.stdin.readline
rep = int(input())

def isgood(a):
	tmp = a[0]
	for i in a:
		if i < tmp:
			return False
		tmp = i
	return True
for _ in range(rep):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if isgood(a):
		print('YES')
		continue
	arr = []
	for i in range(n):
		if i - x < 0 and i + x >= n:
			arr.append((i, a[i]))
	a.sort()
	flag = 1
	for value in arr:
		(i, v) = value
		if a[i] != v:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	line = list(map(int, input().split()))
	line_s = sorted(line)
	for i in range(n):
		if line[i] != line_s[i]:
			if i > n - 1 - i:
				temp = i
			else:
				temp = n - 1 - i
			if temp < x:
				print('NO')
				break
	else:
		print('YES')


from sys import stdin
input = stdin.readline
for i in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	new = arr[:]
	a = max(arr)
	b = min(arr)
	s = set()
	new.sort()
	ans = True
	for i in range(n):
		if new[i] != arr[i]:
			if i >= x or n - 1 - i >= x:
				ans &= True
			else:
				ans &= False
	print('YES' if ans else 'NO')


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = [j for j in map(int, input().split())]
	b = sorted(a)
	flag = 1
	for (i, e) in enumerate(a):
		if e == b[i]:
			continue
		if i < x and n - 1 - i < x:
			flag = 0
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	c = l.copy()
	c.sort()
	h = 0
	s = 0
	a = 0
	for i in range(n):
		if l[i] == c[i]:
			h = h + 1
		elif i >= m or n - i - 1 >= m:
			s = s + 1
		else:
			a = a + 1
	if a > 0:
		print('NO')
	else:
		print('YES')


import math
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if x < math.ceil(n / 2):
		print('YES')
	elif n % 2 == 0 and x == n / 2:
		print('YES')
	else:
		sorted_array = []
		for i in range(len(a)):
			sorted_array.append([a[i], i])
		sorted_array.sort()
		ans = 'YES'
		unswappable_width = x * 2 - n
		u_left = int((n - unswappable_width) / 2)
		u_right = unswappable_width + u_left
		for i in range(u_left, u_right):
			if sorted_array[i][0] != a[i]:
				ans = 'NO'
				break
		print(ans)


import sys
for _ in range(int(sys.stdin.readline())):
	(n, x) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	b = [i for i in a]
	b.sort()
	found = True
	for i in range(n - x, x):
		if a[i] != b[i]:
			found = False
			break
	if found:
		sys.stdout.write('YES\n')
	else:
		sys.stdout.write('NO\n')


import sys
input = sys.stdin.readline

def solve():
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	ref = sorted(arr)
	(i, j) = (n - 1 - x, x)
	for k in range(i + 1, j):
		if arr[k] != ref[k]:
			return 'NO'
	return 'YES'
for _ in range(int(input())):
	print(solve())


from sys import stdin
input = stdin.readline

def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	for i in range(n - x, x):
		if a[i] != b[i]:
			print('NO')
			return
	print('YES')
for _ in range(int(input())):
	solve()


import sys
R = lambda : map(int, next(sys.stdin).split())
(t,) = R()
while t:
	t -= 1
	(n, x) = R()
	(*a,) = R()
	print('YNEOS'[a[-x:x] != sorted(a)[-x:x]::2])


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, x) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().strip().split()))
	b = sorted(a)
	f = 0
	for i in range(n):
		if abs(n - 1 - i) < x and i < x:
			if b[i] != a[i]:
				f = 1
				break
	if f == 0:
		sys.stdout.write('YES\n')
	else:
		sys.stdout.write('NO\n')


import sys
for _ in range(int(sys.stdin.readline())):
	(n, x) = map(int, sys.stdin.readline().split())
	arr = [int(x) for x in sys.stdin.readline().split()]
	if n - x >= x:
		print('YES')
		continue
	sorted_arr = sorted(arr)
	res = True
	for i in range(n - x, x):
		if arr[i] != sorted_arr[i]:
			res = False
			break
	print('YES' if res else 'NO')


import sys
input = sys.stdin.readline
I = lambda : map(int, input().split())
for _ in [0] * int(input()):
	(n, x) = I()
	a = list(I())
	ff = 0
	if x <= n // 2:
		ff = 1
	else:
		b = sorted(a)
		if a[n - x:x] == b[n - x:x]:
			ff = 1
	print('YNEOS'[int(ff == 0)::2])


import math
import heapq
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	(n, x) = M()
	l = L()
	f = 0
	p = l[:]
	l = sorted(enumerate(l), key=lambda x: x[1])
	for i in range(n):
		t = abs(l[i][0] - i)
		if t >= x or l[i][1] == p[i]:
			continue
		elif i > l[i][0] and (l[i][0] - x + t >= 0 or i + x < n):
			continue
		elif i < l[i][0] and (l[i][0] + x - t < n or i - x >= 0):
			continue
		else:
			f = 1
	if f == 1:
		print('NO')
	else:
		print('YES')


import sys
input = lambda : sys.stdin.readline().rstrip()

def solve():
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	B = sorted(A)
	print('YES' if A[n - x:x] == B[n - x:x] else 'NO')
T = int(input())
for i in range(T):
	solve()


def solve(n, x, nums):
	srt = sorted(nums)
	if srt == nums:
		return 'YES'
	if x >= n:
		return 'NO'
	if n >= 2 * x or nums[n - x:x] == srt[n - x:x]:
		return 'YES'
	return 'NO'
ans = []
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	nums = list(map(int, input().split()))
	ans.append(solve(n, x, nums))
print(*ans, sep='\n')