You are given an array $a$ of length $n$.

You are also given a set of distinct positions $p_1, p_2, \dots, p_m$, where $1 \le p_i < n$. The position $p_i$ means that you can swap elements $a[p_i]$ and $a[p_i + 1]$. You can apply this operation any number of times for each of the given positions.

Your task is to determine if it is possible to sort the initial array in non-decreasing order ($a_1 \le a_2 \le \dots \le a_n$) using only allowed swaps.

For example, if $a = [3, 2, 1]$ and $p = [1, 2]$, then we can first swap elements $a[2]$ and $a[3]$ (because position $2$ is contained in the given set $p$). We get the array $a = [3, 1, 2]$. Then we swap $a[1]$ and $a[2]$ (position $1$ is also contained in $p$). We get the array $a = [1, 3, 2]$. Finally, we swap $a[2]$ and $a[3]$ again and get the array $a = [1, 2, 3]$, sorted in non-decreasing order.

You can see that if $a = [4, 1, 2, 3]$ and $p = [3, 2]$ then you cannot sort the array.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 100$) — the number of test cases.

Then $t$ test cases follow. The first line of each test case contains two integers $n$ and $m$ ($1 \le m < n \le 100$) — the number of elements in $a$ and the number of elements in $p$. The second line of the test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 100$). The third line of the test case contains $m$ integers $p_1, p_2, \dots, p_m$ ($1 \le p_i < n$, all $p_i$ are distinct) — the set of positions described in the problem statement.


-----Output-----

For each test case, print the answer — "YES" (without quotes) if you can sort the initial array in non-decreasing order ($a_1 \le a_2 \le \dots \le a_n$) using only allowed swaps. Otherwise, print "NO".


-----Example-----
Input
6
3 2
3 2 1
1 2
4 2
4 1 2 3
3 2
5 1
1 2 3 4 5
1
4 2
2 1 4 3
1 3
4 2
4 3 2 1
1 3
5 2
2 1 2 3 3
1 4

Output
YES
NO
YES
YES
NO
YES

Difficulty: EASY

Solutions:
for __ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	m1 = {}
	m2 = {}
	for i in range(0, n - 1):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
				m1[j] = 1
	for x in b:
		m2[x - 1] = 1
	f = 0
	for x in m1:
		if x in m2:
			pass
		else:
			f = 1
			break
	if f is 1:
		print('NO')
	else:
		print('YES')


def sort_one_index(a, p):
	for i in p:
		if a[i - 1] > a[i]:
			(a[i - 1], a[i]) = (a[i], a[i - 1])
	return a

def weirdsort(a, p):
	b = a.copy()
	a = sort_one_index(a, p)
	while b != a:
		b = a.copy()
		a = sort_one_index(a, p)
	if a == sorted(a):
		return 'YES'
	else:
		return 'NO'
t = int(input())
for t_itr in range(t):
	nm = list(map(int, input().rstrip().split()))
	n = int(nm[0])
	m = int(nm[1])
	a = list(map(int, input().rstrip().split()))
	p = list(map(int, input().rstrip().split()))
	result = weirdsort(a, p)
	print(result)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	d = {}
	k = a[0]
	flag = True
	a1 = sorted(a)
	for i in range(n):
		d[a1[i]] = i
	for i in range(n - 1, -1, -1):
		for j in range(min(d[a[i]], i), max(i, d[a[i]])):
			if j + 1 not in p:
				flag = False
				break
		d[a[i]] -= 1
	if flag == True:
		print('YES')
	else:
		print('NO')


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, M, A, P):
	P = sorted(set(P))
	runs = [[P[0], P[0] + 1]]
	for p in P[1:]:
		if runs[-1][1] == p:
			runs[-1][1] = p + 1
		else:
			runs.append([p, p + 1])
	Asorted = list(A)
	for (start, end) in runs:
		Asorted[start:end + 1] = sorted(Asorted[start:end + 1])
	if Asorted == sorted(A):
		return 'YES'
	return 'NO'
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N, M) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	P = [int(x) - 1 for x in input().split()]
	ans = solve(N, M, A, P)
	print(ans)


import sys
inp = lambda : sys.stdin.readline()
for _ in range(int(input())):
	(n, m) = map(int, inp().split())
	a = list(map(int, inp().split()))
	p = list(map(int, inp().split()))
	flag = 1
	for i in range(n):
		for j in range(n - i - 1):
			if a[j] > a[j + 1]:
				if j + 1 in p:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
				else:
					flag = 0
					break
		if not flag:
			break
	if flag:
		print('YES')
	else:
		print('NO')


from sys import stdin

def cmp(key):
	return a[key]

def judge(index_sort, origin_index, p):
	first = 0
	second = 0
	if index_sort < origin_index:
		(first, second) = (index_sort + 1, origin_index + 1)
	else:
		(first, second) = (origin_index + 1, index_sort + 1)
	while first != second:
		if first in p:
			first += 1
		else:
			return False
	return True
t = int(stdin.readline())
for i in range(t):
	(n, m) = list(map(int, stdin.readline().split(' ')))
	a = list(map(int, stdin.readline().split(' ')))
	p_list = list(map(int, stdin.readline().split(' ')))
	p = {}
	for item in p_list:
		p[item] = 1
	a_sort_index = [i for i in range(n)]
	a_sort_index.sort(key=cmp)
	state = 1
	for i in range(n):
		index_sort = a_sort_index.index(i)
		if not judge(index_sort, i, p):
			state = 0
			break
	if state == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = [0] * (n + 1)
	a[0] = -1
	a[1:n + 1] = list(map(int, input().split()))
	p = list(map(int, input().split()))
	f = 1
	while f:
		f = 0
		for x in range(m):
			if a[p[x]] > a[p[x] + 1]:
				f = 1
				(a[p[x]], a[p[x] + 1]) = (a[p[x] + 1], a[p[x]])
	if a != sorted(a):
		print('NO')
	else:
		print('YES')
	t -= 1


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, m) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	p = list(map(int, sys.stdin.readline().split()))
	judge1 = True
	judge2 = False
	judge3 = True
	while True:
		for i in range(n):
			if i == n - 1:
				judge2 = True
			elif a[i] > a[i + 1]:
				if i + 1 in p:
					temp = a[i]
					a[i] = a[i + 1]
					a[i + 1] = temp
					break
				else:
					judge1 = False
					break
		if judge1 == False:
			judge3 = False
			break
		if judge2 == True:
			break
	if judge3 == True:
		print('YES')
	else:
		print('NO')


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest
from copy import deepcopy
mod = 10 ** 9 + 7
INF = float('inf')

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

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

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))

def inps():
	return sys.stdin.readline()

def inpsl(x):
	tmp = sys.stdin.readline()
	return list(tmp[:x])

def err(x):
	print(x)
	exit()
for _ in range(inp()):
	(n, m) = inpl()
	a = inpl()
	p = set(inpl_1())
	for _ in range(n):
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				if i in p:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			print('NO')
			break
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lis = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for __ in range(n):
		for i in range(n - 1):
			if i + 1 in p and lis[i] > lis[i + 1]:
				(lis[i], lis[i + 1]) = (lis[i + 1], lis[i])
	if lis == sorted(lis):
		print('YES')
		continue
	print('NO')


t = int(input())
for _ in range(t):
	(n, m) = tuple(map(int, input().split()))
	a_list = list(map(int, input().split()))
	check = [False for _ in range(n)]
	for p in list(map(int, input().split())):
		check[p - 1] = True
	start = 0
	while start < n:
		if not check[start]:
			start += 1
			continue
		end = start + 1
		while True:
			if end >= n or not check[end]:
				break
			end += 1
		sorted_list = sorted(a_list[start:end + 1])
		for i in range(end - start + 1):
			a_list[start + i] = sorted_list[i]
		start = end
	end_flag = False
	for i in range(len(a_list) - 1):
		if a_list[i] > a_list[i + 1]:
			print('NO')
			end_flag = True
			break
	if not end_flag:
		print('YES')


from sys import stdin, stdout
import math
import heapq
t = 1

def aint():
	return int(input().strip())

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

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

def main():
	(n, m) = lint()
	l = lint()
	p = lint()
	L = sorted(l)
	for i in range(n):
		j = -1
		for j in range(i, n):
			if l[j] == L[i]:
				break
		for k in range(j - 1, i - 1, -1):
			if k + 1 not in p:
				print('NO')
				return
			else:
				(l[k], l[k + 1]) = (l[k + 1], l[k])
	print('YES')
t = int(input())
for i in range(t):
	main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = set()
	l = list(map(int, input().split()))
	k = set(map(int, input().split()))
	j = sorted(l)
	for x in range(n):
		y = j.index(l[x])
		j[y] = 0
		for i in range(min(x + 1, y + 1), max(x + 1, y + 1)):
			a.add(i)
	print(['NO', 'YES'][a.issubset(k)])


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	a = list((int(i) for i in input().split()))
	b = list((0 for i in range(n)))
	for i in input().split():
		b[int(i) - 1] = 1
	r = 0
	while r < n:
		l = r
		while r < n and b[r] == 1:
			r += 1
		r += 1
		a = a[:l] + sorted(a[l:r]) + a[r:]
	if sorted(a) != a:
		print('NO')
	else:
		print('YES')


I = lambda : map(int, input().split())
for _ in [0] * int(input()):
	(n, m) = I()
	a = list(I())
	p = sorted(list(I()))
	x = sorted(a)
	ff = 1
	st = z = 0
	for cur in p:
		cur = cur - 1
		if cur != z:
			if sorted(a[st:z + 1]) + a[z + 1:cur] != x[st:cur]:
				ff = 0
				break
			else:
				st = cur
		z = cur + 1
	if a[z + 1:] != x[z + 1:]:
		ff = 0
	print('YNEOS'[int(ff == 0)::2])


exec('\nexec("""\\ndef solve(n,m,a,p):\\n    for i in range(n):\\n        for j in p:\\n            if a[j-1]>a[j]:\\n                a[j-1],a[j]=a[j],a[j-1]\\n    if a==sorted(a):\\n        return \'YES\'\\n    return \'NO\'\\nfor _ in range(int(input())):\\n    n,m=map(int,input().split());a=list(map(int,input().strip().split()))[:n];p=sorted(list(map(int,input().strip().split()))[:n])\\n    print(solve(n,m,a,p))\\n""")\n')


for ti in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	p.sort()
	s = [0] * (len(a) + 1)
	for pi in p:
		s[pi - 1] = 1
	(rl, ri) = ([], 0)
	while ri < len(a):
		while ri < len(a) and (not s[ri]):
			rl.append(a[ri])
			ri += 1
		start = ri
		while ri < len(a) and s[ri]:
			ri += 1
		end = ri + 1
		ri += 1
		np = sorted(a[start:end])
		for x in np:
			rl.append(x)
	for i in range(1, len(a)):
		if rl[i] < rl[i - 1]:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for ii in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	ll = []
	for i in range(n):
		ll.append([l[i], i + 1])
	ll.sort()
	q = []
	for i in range(1, n + 1):
		if not i in p:
			q.append(i)
	f = 0
	for i in range(n):
		for j in q:
			a = min(i + 1, ll[i][1])
			b = max(i + 1, ll[i][1])
			if a <= j < b:
				f += 1
	print('YES' if f == 0 else 'NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ls = [int(x) for x in input().split()]
	d = dict()
	l = [int(x) for x in input().split()]
	for i in l:
		d[i - 1] = 1
	for j in range(n):
		for i in range(n - 1):
			if i in d and ls[i] > ls[i + 1]:
				x = ls[i]
				ls[i] = ls[i + 1]
				ls[i + 1] = x
	li = ls[:]
	li.sort()
	if li == ls:
		print('YES')
	else:
		print('NO')


def solve():

	def find(i):
		for j in range(n):
			if i == sa[j]:
				return j

	def check(a, b):
		for i in range(a, b):
			if change[i] == 0:
				return False
		return True
	tc = int(input())
	for t in range(tc):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		change = [0 for _ in range(100)]
		duplicate = [0 for _ in range(101)]
		p = list(map(int, input().split()))
		for i in p:
			change[i - 1] = 1
		sa = sorted(a)
		yes = True
		for i in range(n):
			idx = find(a[i]) + duplicate[a[i]]
			if i < idx:
				if check(i, idx) is False:
					yes = False
					break
			elif check(idx, i) is False:
				yes = False
				break
			duplicate[a[i]] += 1
		if yes:
			print('YES')
		else:
			print('NO')
solve()


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	p = list(map(int, input().strip().split()))
	temp = []
	for j in range(n):
		if j + 1 in p:
			temp.append(1)
		else:
			temp.append(0)
	for a in range(n):
		for b in range(0, n - a - 1):
			if arr[b] > arr[b + 1]:
				if temp[b] == 1:
					(arr[b], arr[b + 1]) = (arr[b + 1], arr[b])
	if arr == sorted(arr):
		print('YES')
	else:
		print('NO')


def solve(a, p):
	arr = a[:]
	arr.append(1000)
	while True:
		c = 0
		for i in p:
			i -= 1
			if arr[i + 1] < arr[i]:
				(arr[i + 1], arr[i]) = (arr[i], arr[i + 1])
			else:
				c += 1
		if c == len(p):
			break
	if arr == sorted(arr):
		return 'YES'
	else:
		return 'NO'
t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	print(solve(a, p))


def swap(x, k):
	temp = li[k]
	li[k] = li[k + 1]
	li[k + 1] = temp
	return li
x = 0
y = 0
li = []
p = []
sorted = []
test = int(input())
for i in range(test):
	(x, y) = list(map(int, input().split()))
	li = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for v in range(len(p)):
		p[v] = p[v] - 1
	for t in range(x):
		for j in range(y):
			if li[p[j]] > li[p[j] + 1]:
				li = swap(li, p[j])
	flag = 0
	i = 1
	while i < len(li):
		if li[i] < li[i - 1]:
			flag = 1
		i += 1
	if not flag:
		print('YES')
	else:
		print('NO')


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
li = lambda : list(map(int, input().split()))

def solve():
	(n, m) = li()
	a = li()
	b = li()
	d = Counter(b)
	for i in range(n):
		for j in range(0, n - i - 1):
			if j + 1 not in d:
				continue
			if a[j] > a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	flag = 0
	for i in range(1, n):
		if a[i - 1] > a[i]:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')
for _ in range(int(input())):
	solve()


for k in range(int(input())):
	(n, m) = map(int, input().split())
	t = [0] + list(map(int, input().split()))
	p = list(map(int, input().split()))
	u = 0
	while True:
		x = 0
		for i in range(1, n):
			if t[i] > t[i + 1]:
				x += 1
				if i in p:
					(t[i], t[i + 1]) = (t[i + 1], t[i])
			else:
				pass
		u += 1
		if x == 0:
			break
		elif u > n:
			break
	if u <= n:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	b = a.copy()
	b.sort()
	if a == b:
		print('YES')
	else:
		for i in range(n):
			for j in p:
				if a[j] < a[j - 1]:
					t = a[j]
					a[j] = a[j - 1]
					a[j - 1] = t
		if a == b:
			print('YES')
		else:
			print('NO')


from sys import *
n = lambda : map(int, stdin.readline().split())
t = [*n()][0]
while t > 0:
	(m, k) = [*n()]
	l = [*n()]
	s = [*n()]
	s.sort()
	(p1, p2) = (s[0] - 1, s[0])
	for i in s[1:]:
		if p2 == i - 1:
			p2 += 1
		elif i - 1 > p2:
			l = l[0:p1] + sorted(l[p1:p2 + 1]) + l[p2 + 1:]
			p1 = i - 1
			p2 = i
	l = l[0:p1] + sorted(l[p1:p2 + 1]) + l[p2 + 1:]
	if l == sorted(l):
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	pl = [1] * n
	for p in map(int, input().split()):
		pl[p - 1] = 0
	prev = 0
	f = 0
	for i in range(n - 1):
		if pl[i]:
			if max(a[prev:i + 1]) > min(a[i + 1:]):
				f = 1
				break
	print('YNEOS'[f::2])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	d = 0
	for i in range(n):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1]:
				if j + 1 in p:
					temp = a[j + 1]
					a[j + 1] = a[j]
					a[j] = temp
				else:
					d = 1
					break
		if d == 1:
			break
	if d == 0:
		print('YES')
	else:
		print('NO')


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

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

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

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

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

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

def SI():
	return sys.stdin.readline()[:-1]

def main():
	t = II()
	for _ in range(t):
		(n, m) = MI()
		aa = LI()
		pp = LI1()
		bb = []
		cur = []
		for p in sorted(pp):
			if not cur:
				if p > 0:
					bb += aa[:p]
				cur = [p]
			elif p == cur[-1] + 1:
				cur.append(p)
			else:
				bb += sorted(aa[cur[0]:cur[-1] + 2])
				bb += aa[cur[-1] + 2:p]
				cur = [p]
		bb += sorted(aa[cur[0]:cur[-1] + 2])
		bb += aa[cur[-1] + 2:]
		aa.sort()
		if aa == bb:
			print('YES')
		else:
			print('NO')
main()


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, m) = R()
	a = [*R()]
	b = sorted({*range(1, n + 1)} - {*R()})
	for (i, j) in zip([0] + b, b + [n]):
		a[i:j] = sorted(a[i:j])
	print('YNEOS'[a > sorted(a)::2])


from collections import defaultdict
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p = [p[j] - 1 for j in range(m)]
	r = sorted(a)
	d = set()
	for j in p:
		d.add(j)
	flag = 0
	for j in range(n):
		z = a[j:].index(r[j])
		z = z + j
		if z > j:
			for k in range(z, j, -1):
				if k - 1 in d:
					(a[k - 1], a[k]) = (a[k], a[k - 1])
				else:
					flag = 1
					break
		else:
			for k in range(j, z, -1):
				if k - 1 in d:
					(a[k - 1], a[k]) = (a[k], a[k - 1])
				else:
					flag = 1
					break
		if flag == 1:
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = [int(a) for a in input().split()]
	p = [int(p) for p in input().split()]
	a1 = sorted(a)
	p.sort()
	p.append(p[m - 1] + 1)
	left = p[0] - 1
	flag = 0
	count = 0
	for i in range(0, m):
		diff = p[i] - p[i + 1]
		if diff == -1:
			count += 1
			if count == 1:
				left = p[i] - 1
				right = p[i]
			else:
				right += 1
			a[left:right + 1] = sorted(a[left:right + 1])
			flag = 1
		else:
			count = 0
			flag = 0
			a[left:p[i] + 1] = sorted(a[left:p[i] + 1])
			s1 = p[i] - 1
			s2 = p[i]
			if a[s1] > a[s2]:
				(a[s1], a[s2]) = (a[s2], a[s1])
	if a == a1:
		print('YES')
	else:
		print('NO')
	t -= 1


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, m) = R()
	a = [*R()]
	p = {*R()}
	i = 0
	for j in range(1, n + 1):
		if not {j} & p:
			a[i:j] = sorted(a[i:j])
			i = j
	print('YNEOS'[a > sorted(a)::2])


def solve(a, b, n, m):
	while True:
		ok = False
		for i in range(n):
			if b[i] and a[i] > a[i + 1]:
				ok = True
				tmp = a[i]
				a[i] = a[i + 1]
				a[i + 1] = tmp
		if not ok:
			break
	res = True
	for i in range(n - 1):
		res = res and a[i] <= a[i + 1]
	return res
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	tmp = list(map(int, input().split()))
	b = [False] * n
	for i in range(m):
		b[tmp[i] - 1] = True
	if solve(a, b, n, m):
		print('YES')
	else:
		print('NO')


test = int(input())
for i in range(test):
	[s, k] = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	has = [0] * (s + 1)
	ans = []
	for j in range(k):
		has[brr[j]] = 1
	for j in range(1, s + 1):
		if has[j] == 0:
			ans.append(j)
	res = []
	fin = []
	ini = 0
	for j in range(len(ans) - 1):
		res.append(arr[ini:ans[j]])
		ini = ans[j]
	res.append(arr[ini:])
	for j in range(len(res)):
		res[j].sort()
		fin.extend(res[j])
	if fin == sorted(arr):
		print('YES')
	else:
		print('NO')


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(n, m) = I()
	a = I()
	p = [0] * (n + 1)
	for i in I():
		p[i - 1] = 1
	ans = 'NO'
	cur = 0
	final = sorted(a)
	for i in range(n):
		if p[i]:
			cur += 1
		else:
			if sorted(a[i - cur:i + 1]) != final[i - cur:i + 1]:
				break
			cur = 0
	else:
		ans = 'YES'
	print(ans)


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	tmpA = a.copy()
	if a == sorted(a):
		print('YES')
	else:
		for i in range(n):
			for k in p:
				if a[k - 1] > a[k]:
					(a[k - 1], a[k]) = (a[k], a[k - 1])
			if a == sorted(a):
				break
		if a == sorted(a):
			print('YES')
		else:
			print('NO')


t = int(input())
for k in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	b = sorted(a)
	flag = 0
	if m > n - 2:
		flag = 0
	else:
		while b != a:
			if flag == 1:
				break
			for i in range(0, n - 1):
				if flag == 1:
					break
				if a[i] > a[i + 1]:
					if p.count(i + 1) == 0:
						flag = 1
						break
					else:
						temp = a[i]
						a[i] = a[i + 1]
						a[i + 1] = temp
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	t -= 1
	(n, m) = [int(c) for c in input().split()]
	ar = [int(c) for c in input().split()]
	ps = [int(c) for c in input().split()]
	sar = sorted(ar)
	pss = [False] * n
	for ec in ps:
		pss[ec - 1] = True
	csar = []
	i = 0
	while i < n:
		tm = []
		while i < n - 1 and pss[i]:
			tm += [ar[i]]
			i += 1
		if i < n:
			tm += [ar[i]]
			i += 1
		csar += sorted(tm)
	print('YES' if csar == sar else 'NO')


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
from itertools import permutations as permu

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	(n, m) = zz()
	a = zzz()
	p = [0] * n
	for i in zzz():
		p[i - 1] = 1
	ma = a[0]
	ma2 = 0
	ok = 1
	for i in range(1, n):
		if not p[i - 1]:
			ma2 = ma
		if ma2 > a[i]:
			ok = 0
			break
		ma = max(ma, a[i])
	if ok:
		print('YES')
	else:
		print('NO')


test_case = int(input())
results = []
for i in range(test_case):
	(n, m) = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	q = list(map(int, input().split(' ')))
	for i in range(len(arr)):
		for j in range(len(arr) - 1, i, -1):
			if arr[j] < arr[j - 1]:
				if j in q:
					(arr[j], arr[j - 1]) = (arr[j - 1], arr[j])
	if sorted(arr) == arr:
		results.append('YES')
	else:
		results.append('NO')
print('\n'.join(results))


import os
import sys
from io import BytesIO, IOBase
from bisect import bisect

def solution(arr, p_arr, n, m):
	arr.insert(0, 0)
	if arr == sorted(arr):
		print('YES')
		return
	s_arr = sorted(arr)
	prev = None
	while True:
		for i in range(n):
			if arr[i] > arr[i + 1]:
				if i in p_arr:
					(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
		if arr == s_arr:
			print('YES')
			return
		if prev:
			if prev == arr:
				print('NO')
				return
		prev = arr[:]

def main():
	t = int(input())
	for _ in range(t):
		(n, m) = [int(x) for x in input().split()]
		arr = [int(x) for x in input().split()]
		p_arr = [int(x) for x in input().split()]
		solution(arr, p_arr, n, m)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


a = int(input())
for i in range(a):
	(l, m) = map(int, input().split())
	r = list(map(int, input().split()))
	z = list(map(int, input().split()))
	flag = 0
	for i in range(len(r) - 1):
		if r[i] > r[i + 1]:
			if i + 1 in z:
				temp = r[i]
				r[i] = r[i + 1]
				r[i + 1] = temp
				j = i
				while j > 0:
					if r[j] < r[j - 1]:
						if j in z:
							temp = r[j - 1]
							r[j - 1] = r[j]
							r[j] = temp
						else:
							flag = 1
							j = 0
							break
					j = j - 1
			else:
				flag = 1
				break
	if flag == 0:
		print('YES')
	else:
		print('NO')


import sys
first = int(sys.stdin.readline())
while first > 0:
	flag = 0
	(a, b) = map(int, sys.stdin.readline().split())
	alist = list(map(int, sys.stdin.readline().split()))
	plist = list(map(int, sys.stdin.readline().split()))
	sorted(plist)
	for i in range(a):
		for j in range(b):
			if alist[plist[j]] < alist[plist[j] - 1]:
				(alist[plist[j]], alist[plist[j] - 1]) = (alist[plist[j] - 1], alist[plist[j]])
	if alist == sorted(alist):
		flag = 1
	if flag:
		print('YES')
		first -= 1
	else:
		print('NO')
		first -= 1


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(n):
		for j in p:
			if a[j - 1] > a[j]:
				(a[j - 1], a[j]) = (a[j], a[j - 1])
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			print('NO')
			break
	else:
		print('YES')


YES = 'YES'
NO = 'NO'

def solve(a, p):
	bridge = [1] * (len(a) - 1)
	sorted_a = list(a)
	sorted_a.sort()
	for i in p:
		bridge[i - 1] = 0
	if sum(bridge) == 0:
		return YES
	groups = []
	temp_group = [a[0]]
	for (index, i) in enumerate(bridge):
		if i == 0:
			temp_group.append(a[index + 1])
		else:
			if len(temp_group) > 0:
				groups.append(temp_group)
			temp_group = [a[index + 1]]
	if len(temp_group):
		groups.append(temp_group)
	new_arr = [item for sublist in groups for item in sorted(sublist)]
	return checkNonDesc(new_arr)

def checkNonDesc(arr):
	for i in range(len(arr) - 1):
		if arr[i] > arr[i + 1]:
			return NO
	return YES
t = int(input())
for x in range(t):
	(len_a, len_p) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	print(solve(a, p))


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		(n, m) = map(int, input().split())
		aa = [int(a) for a in input().split()]
		pp = set((int(a) - 1 for a in input().split()))
		aamx = [aa[0]]
		for a in aa[1:]:
			aamx.append(max(aamx[-1], a))
		aamn = [aa[-1]]
		for a in aa[-2::-1]:
			aamn.append(min(aamn[-1], a))
		aamn.reverse()
		for i in range(n - 1):
			if aamx[i] > aamn[i + 1] and i not in pp:
				print('NO')
				return
		print('YES')
	q = int(input())
	for _ in range(q):
		solve()
main()


t = int(input())
for i in range(0, t):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	if len(a) - len(p) == 1:
		print('YES')
		w = -1
	else:
		w = 1
	while w > 0:
		w = 0
		for x in p:
			if a[x - 1] > a[x]:
				w += 1
				(a[x - 1], a[x]) = (a[x], a[x - 1])
	if a == sorted(a) and w >= 0:
		print('YES')
	elif w >= 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	m = arr[:]
	m.sort()
	p = list(map(int, input().split()))
	p.sort()
	for i in range(len(p)):
		p[i] -= 1
	v = [0] * n
	for i in range(len(p)):
		v[p[i]] = 1
	f = 0
	temp = []
	t = []
	for i in range(n):
		if v[i] == 0:
			t.append(arr[i])
			t.sort()
			temp.append(t)
			t = []
		else:
			t.append(arr[i])
	g = []
	for i in temp:
		g += i
	if g == m:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	p = list(sorted(map(lambda z: int(z) - 1, input().split(' '))))
	groups = []
	bse = 0
	li = 0
	for i in range(1, len(p)):
		if p[i - 1] + 1 == p[i]:
			li = i
		else:
			groups.append([p[bse], p[li] + 1])
			bse = i
			li = i
	groups.append([p[bse], p[li] + 1])
	elms = []
	for i in range(0, groups[0][0]):
		elms.append(a[i])
	for j in range(len(groups) - 1):
		g = groups[j]
		elms += sorted(a[g[0]:g[1] + 1])
		for i in range(g[1] + 1, groups[j + 1][0]):
			elms.append(a[i])
	elms += sorted(a[groups[-1][0]:groups[-1][1] + 1])
	for i in range(groups[-1][1] + 1, len(a)):
		elms.append(a[i])
	wks = True
	for i in range(1, len(elms)):
		if elms[i] < elms[i - 1]:
			print('NO')
			wks = False
			break
	if wks:
		print('YES')


def bubble_sort(ar):
	d = len(ar)
	for i in range(d):
		for j in range(0, d - i - 1):
			if ar[j] > ar[j + 1]:
				if j + 1 not in ap:
					return False
				(ar[j], ar[j + 1]) = (ar[j + 1], ar[j])
	return True
t = int(input())
for u in range(t):
	(n, m) = [int(x) for x in input().split()]
	first = [int(x) for x in input().split()]
	ap = [int(x) for x in input().split()]
	if bubble_sort(first):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	a = sorted([(a[i], i) for i in range(n)])
	p = [p[i] - 1 for i in range(m)]
	flg = True
	for j in range(n):
		start = j
		end = a[j][1]
		if end > start:
			if any((x not in p for x in range(start, end))):
				flg = False
		elif start > end:
			if any((x not in p for x in range(end, start))):
				flg = False
	print('YES' if flg else 'NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	l = a[:]
	l.sort()
	j = 1
	while j <= 1000:
		for i in p:
			i -= 1
			if a[i] >= a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
		if a == l:
			j += 1000
		else:
			j += 1
	if a == l:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	real_arr = sorted(arr)
	prr = list(map(int, input().split()))
	lock = 0
	for i in range(n):
		for j in range(n):
			if arr[i] == real_arr[j]:
				real_arr[j] = -1
				if i + 1 < j + 1:
					for k in range(i + 1, j + 1):
						if k not in prr:
							lock = 1
							break
				elif i + 1 == j + 1:
					break
				else:
					for k in range(j + 1, i):
						if k not in prr:
							lock = 1
							break
				break
		if lock == 1:
			break
	if lock == 1:
		print('NO')
	else:
		print('YES')


for tc in range(int(input())):
	(n, m) = tuple(map(int, input().split()))
	arr = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	pos.sort()
	new_arr = arr.copy()
	if n == m + 1:
		print('YES')
	else:
		for i in range(m - 1):
			if pos[i + 1] - pos[i] > 1:
				new_arr[pos[i] - 1:pos[i] + 1] = sorted(new_arr[pos[i] - 1:pos[i] + 1])
		new_arr[pos[m - 1] - 1:pos[m - 1] + 1] = sorted(new_arr[pos[m - 1] - 1:pos[m - 1] + 1])
		begin = -1
		end = 0
		for i in range(m - 1):
			if pos[i + 1] - pos[i] == 1:
				if begin == -1:
					begin = pos[i]
				end = pos[i + 1]
			elif end > 0:
				new_arr[begin - 1:end + 1] = sorted(new_arr[begin - 1:end + 1])
				begin = -1
				end = 0
		if end > 0:
			new_arr[begin - 1:end + 1] = sorted(new_arr[begin - 1:end + 1])
		arr.sort()
		b = 0
		for i in range(n):
			if arr[i] != new_arr[i]:
				print('NO')
				b = 1
				break
		if b == 0:
			print('YES')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = [False] * n
	for i in list(map(int, input().split())):
		p[i - 1] = True
	i = 0
	while i < n:
		if not p[i]:
			i += 1
			continue
		j = i
		while j < n and p[j]:
			j += 1
		a[i:j + 1] = sorted(a[i:j + 1])
		i = j
	print('YES') if all((a[i] <= a[i + 1] for i in range(n - 1))) else print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = set(list(map(int, input().split())))
	Flag = False
	for j in range(n - 1):
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				if i + 1 in p:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
				else:
					print('NO')
					Flag = True
					break
		if Flag:
			break
	if not Flag:
		print('YES')


t = int(input())
ans = 0
for i in range(0, t):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	p.reverse()
	c = len(p)
	for g in range(0, m):
		for k in range(0, len(p)):
			if a[p[k] - 1] > a[p[k]]:
				(a[p[k] - 1], a[p[k]]) = (a[p[k]], a[p[k] - 1])
	for l in range(1, len(a)):
		if a[l] >= a[l - 1]:
			ans += 1
	if ans == len(a) - 1:
		print('YES')
	else:
		print('NO')
	ans = 0


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p = list(map(lambda x: x - 1, p))
	s = set(p)
	b = []
	l = []
	for i in range(n):
		l.append(a[i])
		if i not in s:
			l.sort()
			b += l
			l = []
	c = a[:]
	c.sort()
	if b == c:
		print('YES')
	else:
		print('NO')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
for _ in range(ii()):
	(n, m) = mi()
	a = li()
	b = sorted(a)
	p = li()
	for _ in range(n):
		for i in range(m):
			if a[p[i] - 1] > a[p[i]]:
				(a[p[i] - 1], a[p[i]]) = (a[p[i]], a[p[i] - 1])
	if a == b:
		print('YES')
	else:
		print('NO')


t = int(input())
answers = []
for ti in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = set(list(map(int, input().split())))
	for i in range(n):
		for j in range(n - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	is_sorted = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			is_sorted = False
			break
	if is_sorted:
		answers.append('YES')
	else:
		answers.append('NO')
for a in answers:
	print(a)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	swap = True
	while swap == True:
		swap = False
		for i in p:
			if a[i - 1] > a[i]:
				(a[i - 1], a[i]) = (a[i], a[i - 1])
				swap = True
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, pn) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = 1
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1]:
				if j + 1 in p:
					(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
				else:
					c = 0
					break
	if c == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	dic = {}
	boo = True
	for i in p:
		dic[i - 1] = 0
	for i in range(n):
		for j in range(n - i - 1):
			if a[j] > a[j + 1] and j not in dic.keys():
				boo = False
			if a[j] > a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	ans = 'YES' if boo else 'NO'
	print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	B.sort()
	k = [B[0] - 1]
	for i in range(1, m):
		if B[i - 1] + 1 == B[i]:
			k.append(B[i] - 1)
		elif k:
			k.append(k[-1] + 1)
			x = A[k[0]:k[-1] + 1]
			x.sort()
			A[k[0]:k[-1] + 1] = x
			k = [B[i] - 1]
	k.append(B[-1] - 1)
	k.append(k[-1] + 1)
	x = A[k[0]:k[-1] + 1]
	x.sort()
	A[k[0]:k[-1] + 1] = x
	if A == sorted(A):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	posd = {}
	for i in range(n):
		arr[i] = (arr[i], i + 1)
	for i in pos:
		posd[i] = True
	arr.sort(key=lambda x: x[0])
	ans = 'YES'
	for i in range(n):
		for j in range(min(i + 1, arr[i][1]), max(i + 1, arr[i][1])):
			if j not in posd:
				ans = 'NO'
				break
		if ans == 'NO':
			break
	print(ans)


def bs(arr):
	n = len(arr)
	s = set([])
	for i in range(n):
		for j in range(n - i - 1):
			if arr[j] > arr[j + 1]:
				s.add(j + 1)
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
	return sorted(list(s))
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	req = bs(a)
	f = True
	for i in req:
		if i in p:
			pass
		else:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split(' '))
		arr = list(map(int, input().split(' ')))
		p = set(map(int, input().split(' ')))
		copy_list = []
		copy_list += arr
		copy_list.sort()
		for i in range(len(arr)):
			for j in range(0, len(arr) - i - 1):
				if arr[j] > arr[j + 1] and j + 1 in p:
					(arr[j + 1], arr[j]) = (arr[j], arr[j + 1])
		if arr == copy_list:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l = [False] * n
	arr = list(map(int, input().split()))
	pi = list(map(int, input().split()))
	for p in pi:
		l[p - 1] = True
	f = True
	i = 0
	while i < n:
		if not l[i]:
			i += 1
			continue
		idx = i
		while idx < n and l[idx]:
			idx += 1
		arr[i:idx + 1] = sorted(arr[i:idx + 1])
		i = idx
	for i in range(len(arr) - 1):
		if arr[i] > arr[i + 1]:
			f = False
			break
	print('YES' if f else 'NO')


from math import *
from collections import *
from functools import *
from bisect import *
from itertools import *
from heapq import *
from statistics import *
inf = float('inf')
ninf = -float('inf')
ip = input
alphal = 'abcdefghijklmnopqrstuvwxyz'
alphau = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def ipl():
	return list(map(int, ip().split()))

def ipn():
	return int(ip())

def ipf():
	return float(ip())

def solve():
	(n, m) = ipl()
	a = ipl()
	p = sorted(ipl())
	i = 0
	while i < m:
		s = i
		i += 1
		while i < m and p[i] - p[i - 1] <= 1:
			i += 1
		a[p[s] - 1:p[i - 1] + 1] = sorted(a[p[s] - 1:p[i - 1] + 1])
	print('YES' if a == sorted(a) else 'NO')
for _ in range(ipn()):
	solve()


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	s = sorted(a)
	p = list(map(int, input().split()))
	for i in range(m):
		p[i] = p[i] - 1
	f = 1
	while f:
		f = 0
		for i in range(m):
			if a[p[i]] > a[p[i] + 1]:
				f = 1
				t = a[p[i]]
				a[p[i]] = a[p[i] + 1]
				a[p[i] + 1] = t
		if a == s:
			break
	if a == s:
		print('YES')
	else:
		print('NO')


import sys, collections
tc = int(sys.stdin.readline())
for _ in range(tc):
	(n, m) = map(int, sys.stdin.readline().split())
	arr = list(map(int, sys.stdin.readline().split()))
	res = list(map(int, sys.stdin.readline().split()))
	res.sort()
	for i in range(m):
		res[i] -= 1
	start = res[0]
	end = res[0]
	for i in range(m):
		if end + 1 in res:
			end += 1
		else:
			arr[start:end + 2] = sorted(arr[start:end + 2])
			start = res[i]
			end = res[i]
	arr[start:end + 2] = sorted(arr[start:end + 2])
	if sorted(arr) == arr:
		print('YES')
	else:
		print('NO')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def checkmonotone(lst):
	lenl = len(lst)
	if lenl == 1:
		return True
	else:
		for i in range(lenl - 1):
			if lst[i] > lst[i + 1]:
				return False
		return True

def gift():
	for _ in range(cou):
		(n, p) = [int(x) for x in input().split()]
		nlst = [int(x) for x in input().split()]
		plst = [int(x) for x in input().split()]
		plst.sort()
		ranges = [[plst[0], plst[0] + 1]]
		for i in range(p - 1):
			currplst = plst[i + 1]
			if currplst == ranges[-1][-1]:
				(rstart, rend) = ranges.pop()
				ranges.append([rstart, currplst + 1])
			else:
				ranges.append([currplst, currplst + 1])
		res = []
		if ranges[0][0] != 1:
			(tosorts, tosorte) = (0, ranges[0][0] - 1)
			templst = nlst[tosorts:tosorte]
			res += templst
		rangen = len(ranges)
		for i in range(rangen):
			(currs, curre) = (ranges[i][0] - 1, ranges[i][1])
			(blanks, blanke) = (False, False)
			if i != rangen - 1:
				(blanks, blanke) = (ranges[i][1], ranges[i + 1][0] - 1)
			elif ranges[-1][1] != n:
				(blanks, blanke) = (ranges[-1][1], n)
			templst = nlst[currs:curre]
			templst.sort()
			res += templst
			if blanks:
				templst1 = nlst[blanks:blanke]
				res += templst1
		if checkmonotone(res):
			yield 'YES'
		else:
			yield 'NO'
cou = int(input())
ans = gift()
print(*ans, sep='\n')


def main():
	total_test_cases = int(input())
	outputs = []
	for _ in range(total_test_cases):
		(m, n) = [int(x) for x in input().split()]
		numbers = [int(x) for x in input().split()]
		positions = [int(x) - 1 for x in input().split()]
		positions = sorted(positions)
		hash_table = {}
		isPossible = True
		for i in range(n):
			hash_table[i] = str(positions[i]) + '' + str(positions[i] + 1)
		for i in range(m):
			for j in range(0, m - i - 1):
				if numbers[j] > numbers[j + 1] and isPossible:
					value = str(j) + '' + str(j + 1)
					if value not in hash_table.values():
						isPossible = False
					else:
						(numbers[j], numbers[j + 1]) = (numbers[j + 1], numbers[j])
		if isPossible:
			outputs.append('YES')
		else:
			outputs.append('NO')
	for each_output in outputs:
		print(each_output)
main()


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	b = list()
	for _ in range(s):
		for i in p:
			if a[i - 1] > a[i]:
				(a[i - 1], a[i]) = (a[i], a[i - 1])
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	for i in range(m):
		p[i] -= 1
	p = set(p)
	r = set()
	i = 0
	while i < n - 1:
		if a[i + 1] < a[i]:
			(a[i], a[i + 1]) = (a[i + 1], a[i])
			r.add(i)
			if i >= 1:
				i -= 1
		elif i <= n - 2:
			i += 1
	if r.issubset(p) and a == sorted(a):
		print('YES')
	else:
		print('NO')


def MaoPao(L, arr, n):
	Len = n
	for i in range(Len - 1):
		for j in range(Len - 1 - i):
			if L[j] > L[j + 1]:
				if j + 1 not in arr:
					return 'NO'
				(L[j], L[j + 1]) = (L[j + 1], L[j])
	return 'YES'
for _ in range(0, int(input())):
	(n, m) = map(int, input().split())
	L = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	print(MaoPao(L, arr, n))


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

def funl():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(n):
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				if i + 1 in p:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
				else:
					return 'NO'
	return 'YES'
for i in range(int(input())):
	print(funl())


for t in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	i = 0
	while i < 101:
		for j in range(m):
			x = p[j] - 1
			if arr[x] > arr[x + 1]:
				(arr[x], arr[x + 1]) = (arr[x + 1], arr[x])
		i += 1
	if sorted(arr) == arr:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split(' ')))
	mm = list(map(int, input().split(' ')))
	y = [i[0] for i in sorted(enumerate(l), key=lambda x: x[1])]
	ln = [0 for i in range(n)]
	for i in range(n):
		if y[i] == i:
			continue
		else:
			for j in range(min(y[i], i), max(y[i], i)):
				ln[j] = 1
	lin = []
	for i in range(n):
		if ln[i] == 1:
			lin.append(i + 1)
	if len(set(lin) - set(mm)) == 0:
		print('YES')
	else:
		print('NO')


import collections

def solve(n, m, arr, pArr):
	pArr.sort()
	i = 0
	while i < m:
		j = i + 1
		while j < m and pArr[j] == pArr[j - 1] + 1:
			j += 1
		dex1 = pArr[i] - 1
		dex2 = pArr[j - 1] + 1
		arr[dex1:dex2] = sorted(arr[dex1:dex2])
		i = j
	for i in range(1, n):
		if arr[i] < arr[i - 1]:
			return False
	return True
t = int(input().strip())
for i in range(t):
	[n, m] = list(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	p = list(map(int, input().strip().split()))
	print('YES' if solve(n, m, arr, p) else 'NO')


def bubbleSort(arr):
	n = len(arr)
	li = []
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1]:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
				li.append(j + 1)
	return li
for _ in range(int(input())):
	(m, n) = map(int, input().split())
	mli = list(map(int, input().split()))
	nli = sorted(list(map(int, input().split())))
	z = sorted(mli)
	if z == mli:
		print('YES')
		continue
	xli = bubbleSort(mli)
	z = set(xli)
	q = set(nli)
	for i in z:
		if i not in q:
			print('NO')
			break
	else:
		print('YES')


testcases = int(input())
for i in range(testcases):
	(n, k) = map(int, input().split())
	LIST = list(map(int, input().split()))
	ANSWER = list(map(int, input().split()))
	RES = sorted(LIST)
	for i in range(len(LIST) - 1):
		for j in range(len(LIST) - i - 1):
			if LIST[j] > LIST[j + 1] and j + 1 in ANSWER:
				(LIST[j], LIST[j + 1]) = (LIST[j + 1], LIST[j])
	if LIST == RES:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	d = {}
	for i in p:
		d[i] = 1
	l = [i for i in range(n)]
	a = list(zip(a, l))
	a.sort()
	dp = [0] * n
	mp = 0
	c = 0
	for i in range(n):
		mi = min(i, a[i][1])
		ma = max(i, a[i][1])
		for j in range(mi, ma):
			dp[j] = 1
	ind = []
	for i in range(n):
		if dp[i] == 1:
			ind.append(i + 1)
	tf = True
	for i in ind:
		if i not in d:
			tf = False
			break
	if tf:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	setp = set([x - 1 for x in p])
	ind = [i + 1 for i in range(len(a))]
	ind.sort(key=lambda x: a[x - 1])
	count = [i + 1 - ind[i] for i in range(len(a))]
	for i in range(len(a)):
		count[ind[i] - 1] = i + 1 - ind[i]

	def solve():
		for i in range(len(a)):
			if count[i] == 0:
				continue
			if count[i] > 0:
				for j in range(i + 1, i + count[i]):
					if j - 1 not in setp:
						print('NO')
						return
			else:
				for j in range(i + count[i], i):
					if j not in setp:
						print('NO')
						return
		print('YES')
		return
	solve()


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	for i in range(int(_input())):
		(m, n) = [int(i) for i in input().split()]
		arr = [int(i) for i in input().split()]
		p = tuple((int(i) - 1 for i in input().split()))
		if len(p) + 1 == len(arr):
			print('YES')
			continue
		f = True
		for i in range(m - 1):
			for j in range(m - 1):
				if arr[j] > arr[j + 1]:
					if j in p:
						(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
					else:
						f = False
						break
		if f:
			print('YES')
		else:
			print('NO')
solution()


import copy

def main():
	t = int(input())
	while t:
		(n, m) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		p = set(map(int, input().split()))
		b = copy.copy(a)
		b.sort()
		posDict = {}
		for i in range(n):
			if b[i] not in posDict:
				posDict[b[i]] = [i]
			else:
				posDict[b[i]].append(i)
		valid = 1
		for i in range(n):
			if b[i] == a[i]:
				diff = 0
			elif i < posDict[a[i]][0]:
				diff = i - posDict[a[i]][0]
			else:
				diff = i - posDict[a[i]][-1]
			if diff < 0:
				for j in range(i + 1, posDict[a[i]][0] + 1):
					if j not in p:
						valid = 0
						break
			elif diff > 0:
				for j in range(posDict[a[i]][-1] + 1, i + 1):
					if j not in p:
						valid = 0
						break
			if not valid:
				break
		if valid:
			print('YES')
		else:
			print('NO')
		t -= 1
main()


for _ in range(int(input())):
	li = list(map(int, input().split()))
	m = li[0]
	n = li[1]
	a_n = [0] * m
	p = list(map(int, input().split()))
	a = list(map(int, input().split()))
	for i in range(n):
		a_n[a[i] - 1] = 1
	while True:
		ok = False
		for i in range(len(p) - 1):
			if a_n[i] == 1 and p[i] > p[i + 1]:
				(p[i], p[i + 1]) = (p[i + 1], p[i])
				ok = True
		if not ok:
			break
	ok = True
	for i in range(m - 1):
		if ok and p[i] <= p[i + 1]:
			ok = True
		else:
			ok = False
	if ok:
		print('YES')
	else:
		print('NO')


def solve():
	for i in range(n):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1]:
				if j + 1 in b:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
				else:
					return 'NO'
	return 'YES'
t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve())
	t -= 1


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	while True:
		changed = False
		for i in p:
			if arr[i - 1] > arr[i]:
				changed = True
				temp = arr[i - 1]
				arr[i - 1] = arr[i]
				arr[i] = temp
		if not changed:
			break
	print('YES' if arr == sorted(arr) else 'NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for j in range(m):
		p[j] -= 1
	f = 0
	for j in range(n - 1):
		if a[j] > a[j + 1]:
			f += 1
	cnt = 0
	while f and cnt < n + 1:
		for j in range(m):
			if a[p[j]] > a[p[j] + 1]:
				(a[p[j]], a[p[j] + 1]) = (a[p[j] + 1], a[p[j]])
		f = 0
		for j in range(n - 1):
			if a[j] > a[j + 1]:
				f += 1
		cnt += 1
	if not f:
		print('YES')
	else:
		print('NO')


for q in range(int(input())):
	(x, n) = list(map(int, input().split()))
	y = list(map(int, input().split()))
	t = list(map(int, input().split()))
	t.sort()
	for d in range(len(t)):
		c = 0
		for i in range(len(t)):
			if y[t[i]] < y[t[i] - 1]:
				(y[t[i]], y[t[i] - 1]) = (y[t[i] - 1], y[t[i]])
				c = c + 1
		if c == 0:
			break
	g = 0
	for j in range(len(y) - 1):
		if y[j + 1] < y[j]:
			g = g + 1
			break
	if g > 0:
		print('NO')
	else:
		print('YES')


I = lambda : map(int, input().split())
for i in range(int(input())):
	(n, m) = I()
	a = list(I())
	p = list(I())
	while a:
		l = list(a)
		for j in p:
			if a[j - 1] > a[j]:
				(a[j - 1], a[j]) = (a[j], a[j - 1])
		if l == a:
			break
	a.sort()
	print(['NO', 'YES'][l == a])


def bubbleSort(arr, p):
	n = len(arr)
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1]:
				if j in p:
					(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
				else:
					return False
	return True
for _ in range(int(input())):
	(n, m) = [int(s) for s in input().split()]
	arr = [int(s) for s in input().split()]
	p = [int(s) - 1 for s in input().split()]
	if bubbleSort(arr, p):
		print('YES')
	else:
		print('NO')


import sys

def controlla(i):
	global res, r, ultimo_ok
	if res == False:
		return
	if i == 0:
		controlla(ultimo_ok + 1)
		return
	if r[i - 1] <= r[i]:
		if i == N - 1:
			return
		else:
			ultimo_ok = max(ultimo_ok, i)
			controlla(ultimo_ok + 1)
	elif P[i - 1] == 1:
		a = r[i]
		r[i] = r[i - 1]
		r[i - 1] = a
		controlla(i - 1)
	else:
		res = False
		return
sys.setrecursionlimit(10000)
T = int(input())
for t in range(T):
	(N, M) = map(int, input().split())
	r = list(map(int, input().strip().split()))
	p = list(map(int, input().strip().split()))
	P = [-1] * N
	for m in range(M):
		a = p[m]
		P[a - 1] = 1
	res = True
	ultimo_ok = 0
	controlla(1)
	if not res:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	temp = input().split(' ')
	n = int(temp[0])
	m = int(temp[1])
	temp = input().split(' ')
	a = list(map(int, temp))
	b = a.copy()
	temp = input().split(' ')
	p = list(map(int, temp))
	b.sort()
	res = 1
	start = 1
	for x in b:
		end = a.index(x) + 1
		a[a.index(x)] = 0
		if all((item in p for item in range(start, end))):
			start += 1
			continue
		else:
			res = 0
			break
	if res == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k1) = map(int, input().split())
	a = list(map(int, input().split()))
	k = list(map(int, input().split()))
	x = set()
	flag = True
	for j in range(n):
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				t = a[i + 1]
				a[i + 1] = a[i]
				a[i] = t
				x.add(i + 1)
	x = list(x)
	x.sort()
	k.sort()
	ok = True
	for i in range(len(x)):
		if x[i] not in k:
			ok = False
	if ok:
		print('YES')
	else:
		print('NO')


t = int(input())
for z in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	a1 = sorted(a)
	boo = True
	d = {}
	for i in range(len(a1)):
		if a1[i] not in d:
			d[a1[i]] = [i]
		else:
			d[a1[i]].append(i)
	if a != a1:
		for i in range(n):
			index = d[a[i]].pop(0)
			if i < index:
				for j in range(i, index):
					if j + 1 not in p:
						boo = False
						break
			else:
				for j in range(index, i - 1):
					if j + 1 not in p:
						boo = False
						break
	print('YES' if boo == True else 'NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = sorted(list(map(int, input().split())))
	x = [0 for i in range(n)]
	for i in range(m):
		num = i + 1
		if x[p[i] - 1] > 0:
			num = x[p[i] - 1]
		(x[p[i] - 1], x[p[i]]) = (num, num)
	a2 = []
	a3 = []
	for i in range(n):
		if i == 0:
			a3.append(a[i])
			continue
		if x[i] == x[i - 1]:
			a3.append(a[i])
		elif x[i - 1] == 0:
			a2 += a3
			a3 = [a[i]]
		else:
			a2 += sorted(a3)
			a3 = [a[i]]
	if x[-1] == 0:
		a2 += a3
	else:
		a2 += sorted(a3)
	if a2 == sorted(a):
		print('YES')
	else:
		print('NO')


def check(n, m, a, p):
	run = True
	sor = sorted(a)
	while run:
		copy = a.copy()
		for i in range(m):
			j = p[i] - 1
			temp = a[j]
			if j < len(a) - 1:
				if a[j + 1] < a[j]:
					a[j] = a[j + 1]
					a[j + 1] = temp
			elif a[j] < a[0]:
				a[j] = a[0]
				a[j] = temp
			if a == sor:
				run = False
		if copy == a:
			run = False
	if sor == a:
		return 'YES'
	else:
		return 'NO'
result = []
t = int(input())
for i in range(t):
	inp = list(map(int, input().split()))
	n = inp[0]
	m = inp[1]
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	result.append(check(n, m, a, p))
for i in result:
	print(i)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	lst = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	x = []
	j = 0
	flag = 0
	while j < n - 1:
		for t in pos:
			if lst[t - 1] > lst[t]:
				(lst[t - 1], lst[t]) = (lst[t], lst[t - 1])
		j += 1
	if lst != sorted(lst):
		print('NO')
	else:
		print('YES')


N = int(input())
for i in range(N):
	d0 = input()
	s0 = d0.split(' ')
	n = int(s0[0])
	m = int(s0[1])
	d1 = input()
	s1 = d1.split(' ')
	d2 = input()
	s2 = d2.split(' ')
	a = [0 for j in range(n)]
	p = [0 for j in range(m)]
	b = [False for j in range(n - 1)]
	for j in range(n):
		a[j] = int(s1[j])
	for j in range(m):
		p[j] = int(s2[j])
	for j in range(m):
		b[p[j] - 1] = True
	aCopy = a.copy()
	a.sort()
	j = 0
	c = [aCopy[0]]
	d = []
	b.append(False)
	while j < n - 1:
		if b[j]:
			c.append(int(aCopy[j + 1]))
		else:
			c.sort()
			for x in c:
				d.append(x)
			c = [aCopy[j + 1]]
		j = j + 1
	c.sort()
	for x in c:
		d.append(x)
	possible = True
	for j in range(n):
		if a[j] != d[j]:
			possible = False
	if possible:
		print('YES')
	else:
		print('NO')


for _ in [0] * int(input()):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = sorted(a)
	l = 0
	while l < len(a):
		for i in p:
			if a[i - 1] > a[i]:
				(a[i - 1], a[i]) = (a[i], a[i - 1])
		l += 1
	if a != c:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	l = list(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	p = list(map(int, input().strip().split()))
	for j in range(l[0]):
		for k in range(l[0] - 1):
			if a[k] > a[k + 1] and k + 1 in p:
				(a[k], a[k + 1]) = (a[k + 1], a[k])
	sum = 1
	for j in range(l[0] - 1):
		if a[j] <= a[j + 1]:
			sum += 1
	if sum == l[0]:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	x = []
	for i in range(n):
		for j in range(n - 1):
			if a[j] > a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
				x.append(j + 1)
	if len(x) == 0:
		print('YES')
	else:
		q = 1
		for i in range(len(x)):
			if x[i] not in p:
				q = 0
				break
		if q == 1:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	n1 = list(map(int, input().split()))
	m1 = list(map(int, input().split()))
	k = n1
	k = sorted(k)
	f = 0
	for i in m1:
		if n1[i - 1] > n1[i]:
			(n1[i - 1], n1[i]) = (n1[i], n1[i - 1])
		for j in m1:
			if n1[j - 1] > n1[j]:
				(n1[j - 1], n1[j]) = (n1[j], n1[j - 1])
			if k == n1:
				f = 1
				break
	if f == 1:
		print('YES')
	else:
		print('NO')


def check(pos, a, b):
	while a <= b:
		if b not in pos:
			return False
		b -= 1
	return True
kk = int(input())
for _ in range(kk):
	(n, m) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	pos = set([int(x) - 1 for x in input().split()])
	target = sorted(arr)
	d = dict()
	for (i, v) in enumerate(arr):
		if v not in d:
			d[v] = [i]
		else:
			d[v].append(i)
	for v in d.values():
		v.sort(reverse=True)
	yes = True
	for (i, t) in enumerate(target):
		p = d[t].pop()
		if not check(pos, i, p - 1):
			yes = False
			break
	print('YES' if yes else 'NO')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = set(map(int, input().split()))
	for __ in range(len(a)):
		for i in range(len(a) - 1):
			if a[i] > a[i + 1] and i + 1 in p:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
	flag = True
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			print('NO')
			flag = False
			break
	if flag:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ai = list(map(int, input().split()))
	pi = list(map(int, input().split()))
	i = 0
	while i < n - 1:
		if ai[i] > ai[i + 1]:
			if i + 1 not in pi:
				print('NO')
				break
			else:
				(ai[i], ai[i + 1]) = (ai[i + 1], ai[i])
				i = -1
		i += 1
	else:
		print('YES')


def check(now, ind):
	if now == ind:
		return True
	elif now < ind and ind - 1 in p:
		return check(now, ind - 1)
	elif now > ind and ind in p:
		return check(now, ind + 1)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = [int(i) - 1 for i in input().split()]
	s = sorted(a)
	ok = True
	for i in range(n):
		if check(i, s.index(a[i])):
			s[s.index(a[i])] = -1
			a[i] = -1
		else:
			ok = False
			break
	if ok:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	array = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	new = array
	for i in range(len(array)):
		for j in range(len(array) - 1):
			if array[j] > array[j + 1]:
				if j + 1 in pos:
					(array[j], array[j + 1]) = (array[j + 1], array[j])
	s = sorted(new)
	if s == array:
		print('YES')
	else:
		print('NO')


import sys
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	d = {}
	for i in range(m):
		d[p[i]] = 1
		d[p[i] + 1] = 2
	a1 = sorted(a)
	flag = 'YES'
	ind = []
	ind1 = []
	for i in range(n):
		if d.get(i + 1) == None:
			if a[i] != a1[i]:
				flag = 'NO'
				break
		elif d.get(i + 1) == 1:
			ind.append(a[i])
			ind1.append(a1[i])
		elif d.get(i + 1) == 2:
			ind.append(a[i])
			ind1.append(a1[i])
			if sorted(ind) != ind1:
				flag = 'NO'
				break
			ind = []
			ind1 = []
	print(flag)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a1 = a.copy()
	a1.sort()
	index = []
	for i in range(n):
		index.append(a.index(a1[i]) + 1)
		a[a.index(a1[i])] = -1
	real = [i + 1 for i in range(n)]
	ans = []
	for i in range(n):
		gap = abs(real[i] - index[i])
		for j in range(gap):
			ans.append(min(real[i], index[i]) + j)
	s = list(set(ans))
	c = 0
	for j in range(len(s)):
		if s[j] in b:
			c += 1
	if c == len(s):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	prr = list(map(int, input().split()))
	for i in range(m):
		prr[i] -= 1
	temp = arr[:]
	temp.sort()
	cnt = 0
	f = 0
	prev = arr[:]
	while cnt < n ** 2:
		for i in range(m):
			(x, y) = (prr[i], prr[i] + 1)
			if arr[x] > arr[y]:
				(arr[x], arr[y]) = (arr[y], arr[x])
				cnt += 1
		if arr == temp:
			f = 1
			break
		if prev == arr:
			break
		prev = arr[:]
	if f == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	b = sorted(a)
	i = 0
	while i < 100:
		for j in range(m):
			x = p[j] - 1
			if a[x] > a[x + 1]:
				(a[x], a[x + 1]) = (a[x + 1], a[x])
		i += 1
	if a == b:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	while p:
		right = p.pop(0)
		left = right - 1
		while p and right + 1 == p[0]:
			right = p.pop(0)
		b = a[left:right + 1]
		b.sort()
		a = a[:left] + b + a[right + 1:]
	ans = 'YES'
	for j in range(1, n):
		if a[j - 1] > a[j]:
			ans = 'NO'
			break
	print(ans)


from sys import stdin

def solve(tc):
	(n, m) = map(int, stdin.readline().split())
	alist = list(map(int, stdin.readline().split()))
	given = list(map(int, stdin.readline().split()))
	origin = set(given)
	cmp = set()
	for i in range(1, n):
		for j in range(i, 0, -1):
			if alist[j] < alist[j - 1]:
				cmp.add(j)
				(alist[j], alist[j - 1]) = (alist[j - 1], alist[j])
			else:
				break
	for e in cmp:
		if e not in origin:
			print('NO')
			return
	print('YES')
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	ck = [False for _ in range(n)]
	for i in p:
		ck[i - 1] = True
	for i in range(n)[::-1]:
		for j in range(i, n - 1):
			if a[j] > a[j + 1] and ck[j]:
				t = a[j]
				a[j] = a[j + 1]
				a[j + 1] = t
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	lcopy = list(l)
	arrcopy = set()
	for u in range(len(l)):
		for j in range(0, len(l) - u - 1):
			if lcopy[j] > lcopy[j + 1]:
				(lcopy[j], lcopy[j + 1]) = (lcopy[j + 1], lcopy[j])
				arrcopy.add(j + 1)
	arr = set(arr)
	if len(arrcopy - arr) == 0:
		print('YES')
	else:
		print('NO')


def bubbleSort(arr):
	n = len(arr)
	se = []
	for i in range(n - 1):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1]:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
				se.append(j + 1)
	return list(set(se))
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	(*a,) = map(int, input().split())
	(*p,) = map(int, input().split())
	ans = bubbleSort(a)
	count = 0
	for k in range(len(ans)):
		for q in range(len(p)):
			if ans[k] == p[q]:
				count += 1
				break
	if count == len(ans):
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	for i in range(n):
		f()

def f():
	(n, m) = map(int, input().split())
	b = list(map(int, input().split()))
	p = list(map(lambda x: int(x) - 1, input().split()))
	a = [[i, False] for i in b]
	for i in range(m):
		a[p[i]][1] = True
	for i in range(n - 1, -1, -1):
		max_ = 0
		index_ = -1
		for j in range(i + 1):
			if a[j][0] >= max_:
				max_ = a[j][0]
				index_ = j
		flag = True
		for x in range(index_, i):
			if a[x][1]:
				(a[x][0], a[x + 1][0]) = (a[x + 1][0], a[x][0])
			else:
				flag = False
				break
		if flag != True:
			break
	if flag:
		print('YES')
	else:
		print('NO')
main()


from collections import deque
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	(*a,) = map(int, input().split())
	b = sorted(a)
	p = set(map(int, input().split()))
	flag = 0
	d = {}
	for i in range(n):
		if b[i] not in d:
			d[b[i]] = deque()
		d[b[i]].append(i)
	for i in range(n):
		idx = d[a[i]].popleft()
		if not all((j + 1 in p for j in range(min(idx, i), max(idx, i)))):
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	b = []
	for i in range(n - 1):
		for j in range(n - i - 1):
			if a[j] > a[j + 1]:
				temp = a[j + 1]
				a[j + 1] = a[j]
				a[j] = temp
				b.append(j + 1)
	k = 0
	for i in b:
		if i not in p:
			k += 1
	if k > 0:
		print('NO')
	else:
		print('YES')


def bubbleSort(arr, n):
	b = set()
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1]:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
				b.add(j + 1)
	return b
t = int(input())
for i in range(t):
	a = []
	p = []
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	b = bubbleSort(a, m)
	f = 0
	for x in b:
		if x in p:
			continue
		else:
			f = 1
			break
	if f == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	p = []
	for i in pos:
		p.append(i - 1)
	k = 0
	if arr == sorted(arr):
		flag = True
	else:
		flag = False
	while k < n + 10 and sorted(arr) != arr:
		for i in p:
			if arr[i] > arr[i + 1]:
				(arr[i + 1], arr[i]) = (arr[i], arr[i + 1])
			if sorted(arr) == arr:
				flag = True
				break
		k += 1
	if flag:
		print('YES')
	else:
		print('NO')


I = input
R = range
for _ in R(int(input())):
	(n, m) = map(int, I().split())
	a = list(map(int, I().split()))
	p = set(map(int, I().split()))
	ans_flag = False
	for __ in R(len(a)):
		sort_flag = True
		for i in R(len(a) - 1):
			if a[i + 1] < a[i]:
				sort_flag = False
				if i + 1 not in p:
					print('NO')
					ans_flag = True
					break
				else:
					temp = a[i]
					a[i] = a[i + 1]
					a[i + 1] = temp
		if sort_flag or ans_flag:
			break
	if not ans_flag:
		print('YES')


t = int(input())
while t:
	t -= 1
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p = set(p)
	for i in range(n):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	flag = 0
	mi = -1000
	for i in range(n):
		if mi <= a[i]:
			mi = a[i]
			continue
		flag = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


col = int(input())
for _ in range(col):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	L = list(map(int, input().split()))
	ind = list(map(int, input().split()))
	while m > 0:
		for i in ind:
			if L[i - 1] > L[i]:
				(L[i - 1], L[i]) = (L[i], L[i - 1])
		m -= 1
	flag = True
	for i in range(n - 1):
		if L[i] > L[i + 1]:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	d = list(map(int, input().split()))
	sum = 1
	for j in range(x[0]):
		for k in range(x[0] - 1):
			if y[k] > y[k + 1] and k + 1 in d:
				(y[k], y[k + 1]) = (y[k + 1], y[k])
	for i in range(x[0] - 1):
		if y[i] <= y[i + 1]:
			sum += 1
	if sum == x[0]:
		print('YES')
	else:
		print('NO')


for k in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	b = sorted(a)
	s = set()
	while a != b:
		for i in range(0, n - 1, 1):
			if a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				s.add(i + 1)
	l2 = list(s)
	result = all((elem in p for elem in l2))
	if result:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split(' '))
	ar = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	d = 0
	for k in range(100):
		for j in range(n):
			if j + 1 in p and ar[j] > ar[j + 1]:
				(ar[j], ar[j + 1]) = (ar[j + 1], ar[j])
		if ar == sorted(ar):
			print('YES')
			d = 1
			break
	if d == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [*map(int, input().split())]
	a = [*map(int, input().split())]
	p = [*map(int, input().split())]
	for _ in a:
		for i in range(len(p)):
			(l, r) = (p[i] - 1, p[i])
			if a[l] > a[r]:
				(a[l], a[r]) = (a[r], a[l])
	print('YES' if all((a[i] <= a[i + 1] for i in range(len(a) - 1))) else 'NO')


t = int(input())
for i in range(t):
	q = input().split()
	n = int(q[0])
	m = int(q[1])
	ll1 = input().split()
	ll2 = input().split()
	l1 = []
	l2 = []
	c = 0
	for j in ll1:
		l1.append(int(j))
	for j in ll2:
		l2.append(int(j))
	lnew = l1.copy()
	lnew.sort()
	for j in range(n):
		for k in range(n - 1):
			if l1[n - k - 2] > l1[n - k - 1]:
				if n - k - 1 not in l2:
					c = 1
					break
				else:
					(l1[n - k - 2], l1[n - k - 1]) = (l1[n - k - 1], l1[n - k - 2])
		if c == 1:
			break
	if c == 1:
		print('NO')
	elif l1 == lnew:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	v = list(map(int, input().split()))
	inp = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	pos = [item - 1 for item in pos]
	inp_sort = list(sorted(inp))
	pos.sort()
	now = 0
	ans = []
	x = []
	ans = [inp[j] for j in range(pos[0])]
	now = pos[0]
	j = 0
	for now in range(pos[0], len(inp)):
		if j < len(pos) and pos[j] == now:
			x.append(inp[now])
			j += 1
		elif now == pos[j - 1] + 1:
			x.append(inp[now])
			x.sort()
			ans += x
			x = []
		else:
			ans.append(inp[now])
	if len(ans) != len(inp):
		ans += inp[pos[-1] + 1:]
	if ans == inp_sort:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(list(map(int, input().split())))
	for i in range(n):
		for j in b:
			if a[j - 1] > a[j]:
				(a[j - 1], a[j]) = (a[j], a[j - 1])
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


t = int(input())
for ts in range(t):
	(l1, l2) = [int(i) for i in input().split()]
	a1 = [int(i) for i in input().split()]
	a2 = [int(i) for i in input().split()]
	w = []
	for i in range(1, l1):
		for j in range(l1 - i):
			if a1[j] > a1[j + 1] and j + 1 in a2:
				(a1[j + 1], a1[j]) = (a1[j], a1[j + 1])
	f = True
	for j in range(l1 - 1):
		if a1[j] > a1[j + 1]:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	(n, m) = map(int, input().split())
	l1 = [int(x) for x in input().split()]
	p = [int(x) - 1 for x in input().split()]
	l2 = l1[:]
	l2.sort()
	f = 1
	while f == 1:
		f = 0
		for j in range(n):
			if j in p:
				if l1[j] > l1[j + 1]:
					(l1[j], l1[j + 1]) = (l1[j + 1], l1[j])
					f = 1
	if l2 == l1:
		print('YES')
	else:
		print('NO')


t = int(input())
ans = []
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = set(map(int, input().split()))
	for j in range(n):
		for i in range(n - 1):
			if i + 1 in p:
				if a[i] > a[i + 1]:
					tmp = a[i]
					a[i] = a[i + 1]
					a[i + 1] = tmp
	a_sort = sorted(a)
	if a == a_sort:
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


def solve():
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	B = set(map(int, input().split()))

	def bubbleSort():
		for i in range(n):
			for j in range(0, n - i - 1):
				if arr[j] > arr[j + 1]:
					if j + 1 not in B:
						return 'NO'
					(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
		return 'YES'
	print(bubbleSort())
for _ in range(int(input())):
	solve()


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	(N, M) = map(int, input().split())
	A = list(map(int, input().split()))
	P = set(map(int, input().split()))
	Query.append((N, M, A, P))
for (N, M, A, P) in Query:
	must = [False] * N
	for (i, a) in enumerate(A):
		cl = False
		for j in range(i):
			if cl or A[j] > a:
				cl = True
				must[j] = True
	ok = True
	for i in range(N):
		if must[i] and (not i + 1 in P):
			ok = False
	print('YES' if ok else 'NO')


t = int(input())
for test in range(t):
	(a, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	flag = True
	while flag:
		cnt = 0
		for i in range(len(p)):
			if arr[p[i] - 1] > arr[p[i]]:
				cnt += 1
				temp = arr[p[i] - 1]
				arr[p[i] - 1] = arr[p[i]]
				arr[p[i]] = temp
		if cnt == 0:
			flag = False
	tarr = sorted(arr)
	if tarr == arr:
		print('YES')
	else:
		print('NO')


def check(a):
	flag = 0
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			flag += 1
			break
	if flag == 0:
		return True
	else:
		return False

def new(a, b):
	for i in range(len(b) - 1, -1, -1):
		if a[b[i]] < a[b[i] - 1]:
			(a[b[i]], a[b[i] - 1]) = (a[b[i] - 1], a[b[i]])
	return a
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b = sorted(b)
	for i in range(len(a)):
		a = new(a, b)
	if check(a):
		print('YES')
	else:
		print('NO')


sc = map(int, open(0).read().split())
ni = lambda : next(sc)
T = ni()
for _ in range(T):
	(N, M) = (ni(), ni())
	A = [ni() for _ in range(N)]
	P = set((ni() - 1 for _ in range(M)))
	B = sorted(A)
	G = []
	T = set()
	cur = 0
	while cur < N:
		while cur < N and cur in P:
			T.add(cur)
			cur += 1
		if cur < N:
			T.add(cur)
		G.append(T)
		T = set()
		cur += 1
	ans = True
	for g in G:
		X = {A[i] for i in g}
		Y = {B[i] for i in g}
		ans &= X == Y
	if ans:
		print('YES')
	else:
		print('NO')


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
for i in range(t()):
	(n, m) = ll()
	a = list(ll())
	p = list(ll())
	b = sorted(a)
	p.sort()
	for j in range(n):
		for i in range(m):
			if a[p[i] - 1] > a[p[i]]:
				(a[p[i] - 1], a[p[i]]) = (a[p[i]], a[p[i] - 1])
	if a == b:
		print('YES')
	else:
		print('NO')


def Cloning(li1):
	li_copy = []
	li_copy.extend(li1)
	return li_copy
t = int(input())
z = []
for i in range(0, t):
	(n, p) = input().split()
	n = int(n)
	p = int(p)
	k = 1
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:p]
	c = Cloning(a)
	a.sort()
	while c != a:
		for j in range(0, n - 1):
			if c[j] > c[j + 1]:
				if j + 1 in b:
					t = c[j]
					c[j] = c[j + 1]
					c[j + 1] = t
				else:
					k = 0
					break
		if k == 0:
			break
	z.append(k)
for i in z:
	if i == 1:
		print('YES')
	else:
		print('NO')


def rindex(l, e):
	res = len(l) - l[::-1].index(e) - 1
	return res
T = int(input())
for t in range(T):
	(n, m) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	P = list(map(int, input().split()))
	sP = set(P)
	sA = sorted(A)
	res = True
	for i in range(n):
		Ai = A[i]
		sAi = sA[i]
		if Ai > sAi:
			j = sA.index(Ai)
			res_tmp = True
			for k in range(i, j - 1):
				if k + 1 not in sP:
					res_tmp = False
			if not res_tmp:
				res = False
				break
		elif Ai < sAi:
			j = rindex(sA, Ai)
			res_tmp = True
			for k in range(i - 1, j - 1, -1):
				if k + 1 not in sP:
					res = False
					break
			if not res_tmp:
				res = False
				break
	print('YES') if res else print('NO')


def wriedsort(arr, p):
	p = sorted(p)
	i = 0
	j = 0
	while i < len(p):
		while j < len(p) and p[i] - p[j] == i - j:
			arr[p[i] - 1:p[j] + 1] = sorted(arr[p[i] - 1:p[j] + 1])
			j += 1
		i = j
	for i in range(len(arr) - 1):
		if arr[i] > arr[i + 1]:
			return 'NO'
	return 'YES'
testcases = int(input())
for i in range(testcases):
	(sizearr, sizecanswap) = map(int, input().split())
	arr = list(map(int, input().split()))
	canswap = list(map(int, input().split()))
	print(wriedsort(arr, canswap))


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
for _ in range(INI()):
	(n, k) = INL()
	A = INL()
	ans = sorted(A)
	S = sorted(INL())
	s = len(S)
	U = []
	for _ in range(s):
		if U == []:
			U.append(S[_])
		elif U[-1] + 1 == S[_]:
			U.append(S[_])
		else:
			A[U[0] - 1:U[-1] + 1] = sorted(A[U[0] - 1:U[-1] + 1])
			U = [S[_]]
	if U != []:
		A[U[0] - 1:U[-1] + 1] = sorted(A[U[0] - 1:U[-1] + 1])
	if ans == A:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	allow = list(map(int, input().split()))
	al = sorted(l)
	for i in range(len(l) - 1):
		for j in range(len(l) - i - 1):
			if l[j] > l[j + 1] and j + 1 in allow:
				(l[j], l[j + 1]) = (l[j + 1], l[j])
	if l == al:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	ans = True
	for i in range(n - 1, -1, -1):
		for j in range(i, n - 1):
			if l[j] > l[j + 1]:
				if j + 1 not in p:
					ans = False
					break
				(l[j], l[j + 1]) = (l[j + 1], l[j])
			else:
				break
		if not ans:
			break
	if not ans:
		print('NO')
	else:
		print('YES')


def find(a, b):
	c = []
	for i in range(1, len(a)):
		if i not in b:
			c.append(i)
	flag = 0
	lmax = 0
	if c:
		for ii in range(0, c[0]):
			if a[ii] > lmax:
				lmax = a[ii]
		for i in range(0, len(c) - 1):
			min = 100
			max = 0
			for ii in range(c[i], c[i + 1]):
				if a[ii] > max:
					max = a[ii]
				if a[ii] < min:
					min = a[ii]
			if lmax > min:
				flag = 1
				break
			lmax = max
		min = 100
		for ii in range(c[-1], len(a)):
			if a[ii] < min:
				min = a[ii]
		if min < lmax:
			flag = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')
a = int(input())
for i in range(a):
	b = input()
	c = input().split(' ')
	d = input().split(' ')
	for i in range(len(c)):
		c[i] = int(c[i])
	for i in range(len(d)):
		d[i] = int(d[i])
	d.sort()
	find(c, d)


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	p = [False for _ in range(n)]
	pos = [int(x) - 1 for x in input().split()]
	for i in pos:
		p[i] = True
	ok = True
	ma = a[0]
	mb = 0
	i = 1
	while i < n and ok:
		if not p[i - 1]:
			mb = ma
		if mb > a[i]:
			ok = False
			break
		ma = max(ma, a[i])
		i += 1
	print(['NO', 'YES'][ok])


import sys

def fast_input():
	return sys.stdin.readline().strip()

def data_input():
	return [int(x) for x in fast_input().split()]

def binary_search(array, x):
	(left, right) = (-1, len(array))
	while left + 1 != right:
		middle = (left + right) // 2
		if array[middle] >= x:
			right = middle
		elif array[middle] < x:
			left = middle
	return right

def solve_of_problem():
	(n, m) = data_input()
	a = data_input()
	k = sorted(a)
	p = sorted(data_input())
	for j in range(n):
		for i in range(m):
			if a[p[i] - 1] > a[p[i]]:
				(a[p[i] - 1], a[p[i]]) = (a[p[i]], a[p[i] - 1])
		if a == k:
			print('YES')
			return
	if a == k:
		print('YES')
	else:
		print('NO')
	return
for ______ in range(int(fast_input())):
	solve_of_problem()


t = int(input())
l1 = []
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for j in range(m):
		for k in p:
			if a[k - 1] > a[k]:
				(a[k - 1], a[k]) = (a[k], a[k - 1])
	if sorted(a) == a:
		l1.append('YES')
	else:
		l1.append('NO')
for item in l1:
	print(item)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def bfs(adj, s, k):
	vis = {i: False for i in adj}
	vis[s] = True
	qu = [s]
	while len(qu) != 0:
		e = qu.pop(0)
		if e == k:
			return True
		for i in adj[e]:
			if vis[i] != True:
				qu.append(i)
				vis[i] = True
	return False
for _ in range(Int()):
	(n, m) = value()
	a = array()
	b = array()
	ind = defaultdict(list)
	a1 = sorted(a)
	for i in range(n):
		ind[a1[i]].append(i + 1)
	adj = defaultdict(list)
	for i in b:
		adj[i].append(i + 1)
		adj[i + 1].append(i)
	f = 1
	yes = False
	for i in range(n):
		if i + 1 in ind[a[i]]:
			ind[a[i]].remove(i + 1)
		else:
			yes = False
			for j in ind[a[i]]:
				if bfs(adj, i + 1, j):
					yes = True
					ind[a[i]].remove(j)
					break
			if yes == False:
				print('NO')
				f = 0
				break
	if f == 1:
		print('YES')


def execute(_n):
	responses = list()
	for i in range(n):
		careless = input('')
		a = input('')
		p = input('')
		numbers = [int(x) for x in a.split(' ') if x.strip()]
		sorted_numbers = [int(x) for x in a.split(' ') if x.strip()]
		sorted_numbers.sort()
		positions = [int(x) for x in p.split(' ') if x.strip()]
		while evaluate(numbers, positions) == True:
			1 + 1
		result = 'YES' if numbers == sorted_numbers else 'NO'
		responses.append(result)
	return responses

def evaluate(_numbers, _positions):
	swapped = False
	for p in _positions:
		if _numbers[p - 1] > _numbers[p]:
			swap(_numbers, p - 1, p)
			swapped = True
	return swapped

def swap(_numbers, p1, p2):
	aux = _numbers[p1]
	_numbers[p1] = _numbers[p2]
	_numbers[p2] = aux

def show_responses(_resp_list):
	for resp in _resp_list:
		print(resp)
n = int(input(''))
show_responses(execute(n))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	sorted_arr = sorted(arr)
	flag = 1
	for i in arr:
		ind = sorted_arr.index(i)
		ch = list(range(arr.index(i) + 1, ind + 1))
		if all((x in p for x in ch)):
			flag = 1
		else:
			flag = 0
			break
		sorted_arr[ind] = -1
		arr[arr.index(i)] = -1
	if flag == 1:
		print('YES')
	else:
		print('NO')


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin, tan

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()

def sieve(x):
	a = [True] * (x + 1)
	sq = floor(sqrt(x))
	for i in range(3, sq + 1, 2):
		if a[i]:
			for j in range(i * i, x + 1, i):
				a[j] = False
	if x > 1:
		p = [2]
	else:
		p = []
	for i in range(3, x + 1, 2):
		if a[i]:
			p.append(i)
	return p

def prime_factor(x):
	c = 1
	i = 0
	while p[i] * p[i] <= x:
		if not x % p[i]:
			c += 1
			while not x % p[i]:
				x //= p[i]
		i += 1
	if x > 1:
		c += 1
	return c
res = ['YES', 'NO']
for _ in range(ii()):
	(n, m) = mi()
	a = li()
	b = set(mi())
	f = 0
	for i in range(n):
		for j in range(n - 1, i, -1):
			if a[i] > a[j]:
				for k in range(i + 1, j + 1):
					if k not in b:
						f = 1
						break
				break
		if f:
			break
	print(res[f])


import sys
import math
import bisect

def solve(A, B):
	n = len(A)
	for i in range(len(B)):
		B[i] -= 1
	for _ in range(n - 1):
		swapped = False
		for b in B:
			if A[b] > A[b + 1]:
				(A[b], A[b + 1]) = (A[b + 1], A[b])
				swapped = True
		if swapped == False:
			break
	return A == sorted(A)

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		A = list(map(int, input().split()))
		B = list(map(int, input().split()))
		if solve(A, B):
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	u = []
	m = l.copy()
	m.sort()
	x = []
	for e in p:
		u.append((e - 1, e))
	k = 0
	while m != l and k < 500:
		k += 1
		for e in u:
			x = l.copy()
			if l[e[0]] > l[e[1]]:
				(l[e[0]], l[e[1]]) = (l[e[1]], l[e[0]])
	if m == l:
		print('YES')
	else:
		print('NO')


def find(x):
	while x != link[x]:
		link[x] = link[link[x]]
		x = link[x]
	return x

def union(x, y):
	x = find(x)
	y = find(y)
	if x != y:
		if size[x] > size[y]:
			size[x] += size[y]
			link[y] = x
		else:
			size[y] += size[x]
			link[x] = y
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	array = list(map(int, input().split()))
	piss = list(map(int, input().split()))
	for i in range(n):
		array[i] = (array[i], i)
	array.sort()
	link = list(range(n))
	size = [1] * n
	for i in piss:
		union(i - 1, i)
	flag = True
	for i in range(n):
		if find(i) != find(array[i][1]):
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	l = [int(x) for x in input().split()]
	n = l[0]
	m = l[1]
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	l = []
	for i in range(0, n - 1):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1]:
				l.append(j + 1)
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if len(l) == 0:
		print('YES')
	else:
		flag = 0
		l = list(set(l))
		for i in l:
			if i not in p:
				flag = 1
				break
		if flag == 0:
			print('YES')
		else:
			print('NO')
	t -= 1


t = int(input(''))
for i in range(t):
	[m, n] = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(n):
		p[i] -= 1
	b = sorted(a)
	for i in range(m):
		for j in range(n):
			if a[p[j]] > a[p[j] + 1]:
				temp = a[p[j] + 1]
				a[p[j] + 1] = a[p[j]]
				a[p[j]] = temp
	flag = 0
	for i in range(m):
		if a[i] != b[i]:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')


def can_be_swapped(rnge, li, result):
	temp = li[rnge[0]:rnge[1] + 1]
	temp.sort()
	temp1 = result[rnge[0]:rnge[1] + 1]
	temp1.sort()
	for i in range(0, len(temp)):
		if temp[i] == temp1[i]:
			continue
		else:
			return False
	for i in range(rnge[0], rnge[1] + 1):
		li[i] = result[i]
	return True

def process():
	(m, n) = list(map(int, input().split()))
	li = list(map(int, input().split()))
	result = sorted(li)
	pos = list(map(int, input().split()))
	pos.sort()
	ranges = []
	temp = []
	for i in range(0, len(pos)):
		if i == 0:
			temp.append(pos[i] - 1)
		elif pos[i] == pos[i - 1] + 1:
			continue
		else:
			temp.append(pos[i - 1] - 1)
			ranges.append(temp)
			temp = [pos[i] - 1]
	if len(pos) >= 2:
		if len(temp) == 1 and pos[-1] == pos[-2] + 1:
			temp.append(pos[-1] - 1)
			ranges.append(temp)
		elif len(temp) == 1 and pos[-1] != pos[-2] + 1:
			temp.append(pos[-2] - 1)
			ranges.append(temp)
			ranges.append([pos[-1] - 1, pos[-1] - 1])
	elif len(temp) == 1:
		temp.append(pos[-1] - 1)
		ranges.append(temp)
	ranges = [[i[0], i[1] + 1] for i in ranges]
	for i in ranges:
		if can_be_swapped(i, li, result):
			continue
		else:
			print('NO')
			return
	for i in range(0, len(li)):
		if li[i] == result[i]:
			continue
		else:
			print('NO')
			return
	print('YES')
tests = int(input())
for i in range(0, tests):
	process()


for n in range(int(input())):
	entry = input()
	a = input().split(' ')
	p = input().split(' ')
	for i in range(len(a)):
		a[i] = int(a[i])
	for i in range(len(p)):
		p[i] = int(p[i]) - 1
	a_sorted = a[:]
	a_sorted.sort()
	while True:
		if a == a_sorted:
			print('YES')
			break
		else:
			flag = False
			for i in range(len(p)):
				if a[p[i]] > a[p[i] + 1]:
					aux = a[p[i]]
					a[p[i]] = a[p[i] + 1]
					a[p[i] + 1] = aux
					flag = True
			if flag:
				continue
			print('NO')
			break


import sys
n = int(input())
for i in range(n):
	(m, p) = map(int, input().strip().split())
	a = []
	arr = [int(i) for i in input().strip().split()]
	for (idx, v) in enumerate(arr):
		a.append((v, idx))
	a = sorted(a)
	pos = [int(i) for i in input().strip().split()]
	ans = 'YES'
	for (idx, v) in enumerate(a):
		(s, e) = (idx, v[1])
		if s > e:
			(s, e) = (e, s)
		for i in range(s, e):
			if i + 1 not in pos:
				ans = 'NO'
				break
		if ans == 'NO':
			break
	print(ans)


nCases = int(input())

def mySort(nums, swaps):
	for _ in range(len(nums)):
		for i in range(len(nums)):
			if i + 1 in swaps:
				if nums[i] > nums[i + 1]:
					temp = nums[i + 1]
					nums[i + 1] = nums[i]
					nums[i] = temp
	return nums
for _ in range(nCases):
	(nNums, nSwaps) = [int(x) for x in input().split()]
	nums = [int(x) for x in input().split()]
	swaps = [int(x) for x in input().split()]
	done = mySort(nums, swaps)
	check = sorted(done)
	if done == check:
		print('YES')
	else:
		print('NO')


import sys

def main():
	res = []
	n = int(input())
	for i in range(n):
		map(int, input().split())
		a = list(map(int, input().split()))
		p = [x - 1 for x in list(map(int, input().split()))]
		again = True
		while again:
			again = False
			for j in p:
				if a[j] > a[j + 1]:
					temp = a[j]
					a[j] = a[j + 1]
					a[j + 1] = temp
					again = True
		if a == sorted(a):
			res.append('YES')
		else:
			res.append('NO')
	for el in res:
		print(el)
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = set(map(int, input().split()))
	for _ in range(n):
		for i in range(n - 1):
			if a[i] > a[i + 1] and i + 1 in set(p):
				(a[i], a[i + 1]) = (a[i + 1], a[i])
	flag = 0
	for j in range(n - 1):
		if a[j] > a[j + 1] and j + 1 not in set(p):
			print('NO')
			flag = 1
			break
	if flag == 0:
		print('YES')


from sys import stdin
r = stdin.readline

def is_sorted(a):
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			return False
	return True

def solve(a, p, n, m):
	p = set(p)
	for times in range(n ** 2 + 5):
		i = 0
		while i < n - 1:
			if a[i] > a[i + 1] and i + 1 in p:
				tmp = a[i]
				a[i] = a[i + 1]
				a[i + 1] = tmp
			i += 1
	return is_sorted(a)

def main():
	cases = int(r())
	for case in range(cases):
		(n, m) = map(int, r().strip().split())
		a = list(map(int, r().strip().split()))
		p = list(map(int, r().strip().split()))
		print('YES' if solve(a, p, n, m) else 'NO')
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(n):
		for pi in p:
			if a[pi - 1] > a[pi]:
				(a[pi], a[pi - 1]) = (a[pi - 1], a[pi])
	if sorted(a) == a:
		print('YES')
	else:
		print('NO')


import re, math, decimal, bisect

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]

def round(n):
	return int(n + 0.5)
DEBUG = 1
DEBUG = 0

def debug(*args, **kwargs):
	if DEBUG:
		print(*args, **kwargs)

def bubblesort(arr, pos):
	debug(arr)
	sort = False
	while True:
		sort = True
		swaps = 0
		for i in range(len(arr) - 1):
			if arr[i] > arr[i + 1]:
				sort = False
				if i in pos:
					swaps += 1
					tmp = arr[i]
					arr[i] = arr[i + 1]
					arr[i + 1] = tmp
		debug(arr, '\n', swaps, sort)
		if swaps == 0:
			break
	return sort
n = iread()
for _ in range(n):
	(m, n) = viread()
	arr = viread()
	pos = set([int(x) - 1 for x in input().strip().split()])
	print(['NO', 'YES'][int(bubblesort(arr, pos))])


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	can = [False] * n
	for i in p:
		can[i - 1] = True
	f = False
	for j in range(n):
		for i in range(n - 1):
			if a[i] > a[i + 1] and can[i]:
				(x, y) = (a[i], a[i + 1])
				a[i] = y
				a[i + 1] = x
			elif a[i] > a[i + 1] and (not can[i]):
				f = True
			else:
				pass
	if f:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	(n, m) = mp()
	arr = lmp()
	p = lmp()
	p.sort()
	ans = sorted(arr)
	t = True
	for i in range(n):
		if i + 1 not in p:
			if sorted(arr[:i + 1]) != ans[:i + 1]:
				t = False
				break
	print('YES' if t else 'NO')


from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')

def solve(n, m, a, p):
	p = set(map(lambda x: x - 1, p))
	sa = sorted(a)
	for i in range(n):
		if sa[i] != a[i]:
			j = i
			found = False
			while j + 1 < len(a) and j in p:
				if a[j + 1] == sa[i]:
					a[j + 1] = a[i]
					a[i] = sa[i]
					found = True
				j += 1
			if not found:
				return False
	return True
for i in range(int_in()):
	(n, m) = arr_in()
	a = arr_in()
	p = arr_in()
	bool_out(solve(n, m, a, p))


t = int(input().strip())
result = []
for i in range(t):
	x = list(map(int, input().strip().split()))
	(n, m) = (x[0], x[1])
	numbers = list(map(int, input().strip().split()))
	positions = list(map(int, input().strip().split()))
	changes = set()
	for k in range(n):
		for j in range(0, n - k - 1):
			if numbers[j] > numbers[j + 1]:
				(numbers[j], numbers[j + 1]) = (numbers[j + 1], numbers[j])
				changes.add(j + 1)
	flag = True
	for s in changes:
		if s not in positions:
			flag = False
			break
	if flag:
		result.append('YES')
	else:
		result.append('NO')
for i in result:
	print(i)


q = int(input())
for rwre in range(q):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	ll = l.copy()
	p = list(map(int, input().split()))
	p.sort()
	i = 0
	while i < 100000:
		i += 1
		if l[p[i % m] - 1] > l[p[i % m]]:
			a = l[p[i % m] - 1]
			b = l[p[i % m]]
			l[p[i % m] - 1] = b
			l[p[i % m]] = a
	ll.sort()
	if l == ll:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	i = 0
	k = p[i]
	j = p[i] + 1
	while i < m - 1:
		if p[i] + 1 == p[i + 1]:
			j = p[i + 1] + 1
		else:
			a[k - 1:j] = sorted(a[k - 1:j])
			k = p[i + 1]
			j = p[i + 1] + 1
		i += 1
	a[k - 1:j] = sorted(a[k - 1:j])
	f = 0
	for i in range(n - 1):
		if a[i] <= a[i + 1]:
			continue
		else:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


def binSearch(a, searchKey, l, r):
	if l > r:
		return False
	else:
		mid = (l + r) // 2
		if a[mid] == searchKey:
			return True
		elif a[mid] < searchKey:
			return binSearch(a, searchKey, mid + 1, r)
		else:
			return binSearch(a, searchKey, l, mid - 1)
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	swap_indices = {}
	for i in range(n):
		arrSorted = True
		for j in range(n - i - 1):
			if a[j] > a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
				arrSorted = False
				if j + 1 not in swap_indices.keys():
					swap_indices[j + 1] = 1
		if arrSorted == True:
			break
	SI_keys = list(swap_indices.keys())
	b.sort()
	flag = True
	for k in range(len(SI_keys)):
		if binSearch(b, SI_keys[k], 0, m - 1) == False:
			print('NO')
			flag = False
			break
	if flag == True:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = sorted(list(map(int, input().split())))
	start = p[0]
	end = p[0]
	for i in range(1, m):
		if p[i] == p[i - 1] + 1:
			end = p[i]
		else:
			l[start - 1:end + 1] = sorted(l[start - 1:end + 1])
			start = p[i]
			end = p[i]
	l[start - 1:end + 1] = sorted(l[start - 1:end + 1])
	if l == sorted(l):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	pr = set(map(int, input().split()))
	flag = True
	co = ar.copy()
	co.sort()
	i = 0
	while ar != co:
		if i == n - 1:
			break
		if ar[i] > ar[i + 1]:
			if i + 1 in pr:
				xx = ar[i]
				ar[i] = ar[i + 1]
				ar[i + 1] = xx
				i = 0
			else:
				flag = False
				break
		else:
			i += 1
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = set(map(int, input().split()))
	(mx, hmx) = (0, 0)
	for i in range(len(a)):
		ai = a[i]
		if i + 1 in p:
			hmx = max(hmx, ai)
			if mx > ai:
				print('NO')
				break
		elif i in p:
			if mx > ai:
				print('NO')
				break
			mx = max(mx, hmx, ai)
		else:
			mx = max(mx, hmx)
			if mx > ai:
				print('NO')
				break
			mx = ai
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	A = list(map(int, input().split()))
	P = list(map(int, input().split()))
	P.append(a + 2)
	B = A.copy()
	B.sort()
	P.sort()
	a1 = P[0]
	b1 = P[0]
	C = []
	NA = []
	PA = []
	for i in range(b):
		if P[i + 1] == P[i] + 1:
			b1 = P[i + 1]
		else:
			C.append([a1 - 1, b1 + 1])
			a1 = P[i + 1]
			b1 = P[i + 1]
	for i in range(len(C)):
		NA = A[C[i][0]:C[i][1]]
		NA.sort()
		A[C[i][0]:C[i][1]] = NA
	if A == B:
		print('YES')
	else:
		print('NO')


def func(l, l1, n, m):
	b = True
	for i in range(n):
		for j in range(0, n - i - 1):
			if l[j] > l[j + 1]:
				if j + 1 not in l1:
					b = False
					break
				(l[j], l[j + 1]) = (l[j + 1], l[j])
	if b == True:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	print(func(l, l1, n, m))


for _ in range(int(input())):
	d = list(map(int, input().split()))
	g = list(map(int, input().split()))
	op = sorted(g)
	p = list(map(int, input().split()))
	p.sort()
	count = 0
	arr1 = [0] * d[0]
	for i in range(d[1]):
		arr1[p[i] - 1] = 1
	case = True
	lol = []
	lolr = []
	for j in range(d[0]):
		if arr1[j] == 0:
			lol.append(g[j])
			lolr.append(op[j])
			lol.sort()
			if lol != lolr:
				case = False
				print('NO')
				break
			lol = []
			lolr = []
		else:
			lol.append(g[j])
			lolr.append(op[j])
	if case:
		print('YES')


n = int(input())
for x in range(n):
	s = input().split(' ')
	a = input().split(' ')
	a = list(map(int, a))
	p = input().split(' ')
	p = list(map(int, p))
	a1 = a.copy()
	a1.sort()
	if a1 == a:
		print('YES')
		continue
	else:
		sw = True
		while a1 != a and sw:
			for numbers in range(len(a) - 1):
				if a[numbers] > a[numbers + 1]:
					if p.count(numbers + 1) > 0:
						y = a[numbers + 1]
						a[numbers + 1] = a[numbers]
						a[numbers] = y
					else:
						sw = False
		if not sw:
			print('NO')
		else:
			print('YES')


t = int(input())
for q in range(t):
	flag = True
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(n):
		for j in range(n - 1):
			if flag:
				if a[j] > a[j + 1]:
					if j + 1 in p:
						(a[j], a[j + 1]) = (a[j + 1], a[j])
					else:
						print('NO')
						flag = False
	if flag:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	while True:
		flag = False
		for i in range(n - 1):
			if i + 1 in p and a[i] > a[i + 1]:
				flag = True
				(a[i], a[i + 1]) = (a[i + 1], a[i])
		if not flag:
			break
	flag = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	yes = [0 for i in range(n)]
	for i in p:
		yes[i - 1] = 1
	sorA = sorted(a)
	flag = 1
	for i in range(n):
		j = i
		while j < n and a[j] != sorA[i]:
			if yes[j] == 1:
				j += 1
			else:
				flag = 0
				break
		if flag == 1:
			if j == n:
				flag = 0
				break
			else:
				for t in range(j, i, -1):
					(a[t], a[t - 1]) = (a[t - 1], a[t])
	if flag == 0:
		print('NO')
	else:
		print('YES')


T = int(input())
for kkk in range(T):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	b = []
	for i in a:
		b.append(i)
	b.sort()
	(i, j) = (0, 0)
	while j < m - 1:
		if p[j + 1] - p[j] > 1:
			a[p[i] - 1:p[j] + 1] = sorted(a[p[i] - 1:p[j] + 1])
			i = j + 1
		j = j + 1
	a[p[i] - 1:p[j] + 1] = sorted(a[p[i] - 1:p[j] + 1])
	f = 1
	for i in range(n):
		if a[i] != b[i]:
			f = 0
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
import datetime
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(int(input())):
		(n, m) = [int(x) for x in input().split()]
		a = [int(x) for x in input().split()]
		p = [int(x) for x in input().split()]
		d = {}
		for i in p:
			d[i - 1] = 1
		b = sorted(a)
		ma = 0
		ans = 'YES'
		for i in range(n):
			t = 0
			for j in range(n):
				if a[i] == b[j]:
					c = 0
					for k in range(min(i, j), max(i, j)):
						if k in d:
							c += 1
					if c == abs(i - j):
						t = 1
				if t == 1:
					break
			if t == 0:
				ans = 'NO'
				break
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	ar = a[:]
	ar.sort()
	while 1:
		count = 0
		for i in p:
			if a[i - 1] > a[i]:
				count = 1
				(a[i - 1], a[i]) = (a[i], a[i - 1])
		if count == 0 and a != ar:
			print('NO')
			break
		if a == ar:
			print('YES')
			break


class Graph:

	def __init__(self, V):
		self.V = V
		self.adj = [[] for i in range(V)]

	def DF(self, temp, v, visited):
		visited[v] = True
		temp.append(v)
		for i in self.adj[v]:
			if visited[i] == False:
				temp = self.DF(temp, i, visited)
		return temp

	def add(self, v, w):
		self.adj[v].append(w)
		self.adj[w].append(v)

	def cc(self):
		visited = []
		cc = []
		for i in range(self.V):
			visited.append(False)
		for v in range(self.V):
			if visited[v] == False:
				temp = []
				cc.append(self.DF(temp, v, visited))
		return cc
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	positions = list(map(int, input().split()))
	g = Graph(n)
	for j in positions:
		g.add(j - 1, j)
	results = g.cc()
	for j in results:
		temp = a[min(j):max(j) + 1]
		temp.sort()
		a[min(j):max(j) + 1] = temp
	failed = False
	for j in range(1, n):
		if a[j - 1] > a[j]:
			failed = True
			break
	if failed == True:
		print('NO')
	else:
		print('YES')


t = int(input())
m = []
n = []
a = []
p = []
srt = []
flag = True
for i in range(t):
	(M, N) = list(map(int, input().split()))
	m.append(M)
	n.append(N)
	A = list(map(int, input().split()))
	a.append(A)
	P = list(map(int, input().split()))
	p.append(P)
	A = []
	P = []
for i in range(t):
	srt = sorted(a[i])
	while srt != a[i]:
		for j in range(len(a[i])):
			if j + 1 < len(a[i]):
				if a[i][j] > a[i][j + 1] and j + 1 not in p[i]:
					flag = False
					break
				elif a[i][j] > a[i][j + 1] and j + 1 in p[i]:
					(a[i][j], a[i][j + 1]) = (a[i][j + 1], a[i][j])
		if flag == False:
			flag = True
			print('NO')
			break
	if a[i] == srt:
		print('YES')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	aa = a[:]
	aa.sort()
	for j in range(n - 1):
		for c in p:
			if c < n and a[c] < a[c - 1]:
				(a[c], a[c - 1]) = (a[c - 1], a[c])
	if a == aa:
		print('YES')
	else:
		print('NO')


test = int(input())
for iter in range(test):
	(n, m) = [int(x) for x in input().split()]
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	flag = False
	for j in range(0, len(a) - 1):
		if a[j] > a[j + 1]:
			flag = True
			break
	if flag == False:
		print('YES')
	while flag:
		x = 0
		for i in p:
			ind = i - 1
			if a[ind] > a[ind + 1]:
				x = 1
		if x == 0:
			print('NO')
			break
		for i in p:
			ind = i - 1
			if a[ind] > a[ind + 1]:
				t = a[ind]
				a[ind] = a[ind + 1]
				a[ind + 1] = t
			flag = False
			for j in range(0, len(a) - 1):
				if a[j] > a[j + 1]:
					flag = True
					break
			if flag == False:
				print('YES')
				break


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	flag = 0
	b = a[:]
	z = a[:]
	b.sort()
	p.sort()
	count = -1
	if len(p) >= len(a) - 1 or a == b:
		flag = 1
		print('YES')
	if flag == 0:
		while 1:
			if a != b:
				count = 0
				for i in p:
					if a[i - 1] > a[i]:
						count = 1
						c = a[i - 1]
						a[i - 1] = a[i]
						a[i] = c
				if count == 0:
					print('NO')
					break
			else:
				print('YES')
				break


t = int(input())

def check(a, b):
	for (i, j) in zip(a, b):
		if i == j:
			continue
		else:
			return False
	return True
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = False
	g = sorted(a)
	if check(g, a):
		print('YES')
		continue
	flag = False
	temp = list(a)
	while True:
		if check(g, a):
			flag = True
			break
		for i in b:
			if i - 1 < n - 1 and a[i - 1] > a[i]:
				(a[i - 1], a[i]) = (a[i], a[i - 1])
		if check(temp, a):
			flag = False
			break
		else:
			temp = list(a)
	if flag:
		print('YES')
	else:
		print('NO')


def check(arr, p, n):
	for i in range(len(p)):
		p[i] = p[i] - 1
	for _ in range(n):
		for j in p:
			if arr[j] > arr[j + 1]:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
	return arr
for _ in range(int(input())):
	(l1, l2) = map(int, input().split())
	arr = list((int(i) for i in input().split()))
	p = list((int(i) for i in input().split()))
	arr1 = check(arr, p, l1)
	if sorted(arr) == arr1:
		print('YES')
	else:
		print('NO')


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, m) = list(map(int, stdin.readline().rstrip().split(' ')))
	a = list(map(int, stdin.readline().rstrip().split(' ')))
	p = list(map(int, stdin.readline().rstrip().split(' ')))
	aSorted = sorted(a)
	pSorted = sorted(p, reverse=True)
	prefixP = [0] * (n + 1)
	for ele in pSorted:
		ele -= 1
		if prefixP[ele + 1] != 0:
			prefixP[ele] = prefixP[ele + 1]
		else:
			prefixP[ele] = ele + 1
	for i in range(n):
		reqIdx = aSorted.index(a[i])
		aSorted[reqIdx] = -1
		if reqIdx == i:
			continue
		elif reqIdx > i and reqIdx > prefixP[i]:
			print('NO')
			break
	else:
		print('YES')


a1 = int(input())
for i1 in range(a1):
	arr = [int(x) for x in input().split()]
	(n, m) = (arr[0], arr[1])
	a = [int(x) for x in input().split()]
	arr = sorted(a)
	p = [int(x) for x in input().split()]
	f = 0
	for i in range(n - 1):
		if i + 1 not in p:
			if arr[:i + 1] != sorted(a[:i + 1]):
				f = 1
				break
	if f == 0:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(lambda x: int(x) - 1, input().split()))
	p.sort()
	s = a[:]
	s.sort()
	j = 0
	k = 0
	for i in range(n - 1):
		if k < m and i == p[k]:
			k += 1
		else:
			b = a[j:i + 1]
			b.sort()
			if s[j:i + 1] != b:
				print('NO')
				break
			else:
				j = i + 1
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = set(map(int, input().split()))
	i = 0
	ans = []
	while i != n:
		if i + 1 in p:
			tmp = [a[i], a[i + 1]]
			i += 2
			while i in p:
				tmp.append(a[i])
				i += 1
			ans += sorted(tmp)
		else:
			ans.append(a[i])
			i += 1
	if ans == sorted(ans):
		print('YES')
	else:
		print('NO')


def resolve_array(a, pos, m):
	i = 0
	while i < m:
		for p in pos:
			e_next = p
			e_current = p - 1
			if a[e_next] < a[e_current]:
				(a[e_next], a[e_current]) = (a[e_current], a[e_next])
		i += 1
	print('YES' if all((a[i] <= a[i + 1] for i in range(len(a) - 1))) else 'NO')
t = int(input())
i = 0
while i < t:
	(n, m) = input().split()
	a = [int(e) for e in input().split()]
	pos = [int(e) for e in input().split()]
	resolve_array(a, pos, int(m))
	i += 1


def solve(n, m, a, p):
	a = [(v, ai) for (ai, v) in enumerate(a)]
	sorted_a = sorted(a)
	target_idx = {}
	for si in range(n):
		(v, ai) = sorted_a[si]
		target_idx[ai] = si
	for (v, ai) in a:
		ti = target_idx[ai]
		if ai < ti:
			(less, more) = (ai, ti)
		else:
			(less, more) = (ti, ai)
		for j in range(less, more):
			if j not in p:
				return 'NO'
	return 'YES'
T = int(input())
for t in range(T):
	(n, m) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	p = set(map(lambda x: int(x) - 1, input().split()))
	print(solve(n, m, a, p))


T = int(input())
for _ in range(T):
	count = 0
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	P = list(map(int, input().split()))
	while 1:
		x = 0
		for i in range(0, n - 1):
			if A[i] > A[i + 1]:
				if i + 1 in P:
					x = 1
					t = A[i]
					A[i] = A[i + 1]
					A[i + 1] = t
		if x == 0:
			break
	if A == sorted(A):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ls = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = ls
	a = sorted(a)
	for i in range(n):
		swap = 0
		for j in range(n - 1 - i):
			if ls[j] > ls[j + 1] and j + 1 in b:
				(ls[j], ls[j + 1]) = (ls[j + 1], ls[j])
				swap += 1
		if swap == 0:
			break
	if a == ls:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	L = list(map(int, input().split()))
	M = list(map(int, input().split()))
	flag = 1
	for i in range(n):
		top = i
		for j in range(n - 1, i, -1):
			if L[i] > L[j]:
				top = j + 1
				break
		for j in range(i + 1, top):
			if j in M:
				continue
			else:
				flag = 0
				break
		if flag == 0:
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


def run_case():
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	conn = [False] * n
	for i in p:
		conn[i - 1] = True
	for i in range(n - 1):
		if not conn[i]:
			left = max(a[:i + 1])
			right = min(a[i + 1:])
			if left > right:
				return 'NO'
	return 'YES'

def main():
	number_of_cases = int(input())
	for i in range(number_of_cases):
		print(run_case())
main()


t = int(input())
for o in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	tmp = 0
	can = True
	for j in range(len(p)):
		p[j] -= 1
	for k in range(len(a)):
		for i in range(0, len(a) - 1):
			if a[i] > a[i + 1]:
				if i in p:
					tmp = a[i]
					a[i] = a[i + 1]
					a[i + 1] = tmp
				else:
					can = False
					break
	if can:
		print('YES')
	else:
		print('NO')


from collections import defaultdict as dd
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	d = dd(int)
	for i in p:
		d[i] = 1
	for i in range(n):
		for j in range(n - 1):
			if a[j] > a[j + 1] and d[j + 1]:
				temp = a[j]
				a[j] = a[j + 1]
				a[j + 1] = temp
	flag = 0
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input(''))
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	a1 = sorted(a)
	while 1:
		c = 0
		for j in range(n - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				temp = a[j]
				a[j] = a[j + 1]
				a[j + 1] = temp
				c = 1
		if c == 0:
			break
	if a == a1:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = sorted(map(int, input().split()))
	z = 0
	ans = 'NO'
	while z < 100:
		for i in p:
			i -= 1
			if a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
		f = 1
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				f = 0
				break
		if f:
			ans = 'YES'
			break
		z += 1
	print(ans)


t = int(input())
while t:
	t -= 1
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(m):
		for j in range(m):
			if a[p[j] - 1] > a[p[j]]:
				(a[p[j] - 1], a[p[j]]) = (a[p[j]], a[p[j] - 1])
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


t = int(input())
for w in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	p = list(map(int, input().split()))
	p = set(p)
	x = False
	for i in range(n - 1):
		for j in range(n - i - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
			elif a[j] > a[j + 1] and (not j + 1 in p):
				print('NO')
				x = True
				break
		if x:
			break
	if a == b:
		print('YES')


t = int(input())
test_cases = [[input() for j in range(3)] for i in range(t)]

def solve(test_case):
	(n, m) = map(int, test_case[0].split())
	A = list(map(int, test_case[1].split()))
	P = list(map(int, test_case[2].split()))
	while True:
		decreasing = False
		swapped = False
		for i in range(n - 1):
			if A[i] > A[i + 1]:
				decreasing = True
				if i + 1 in P:
					tmp = A[i]
					A[i] = A[i + 1]
					A[i + 1] = tmp
					swapped = True
		if swapped:
			continue
		elif decreasing:
			print('NO')
			return
		else:
			print('YES')
			return
for test_case in test_cases:
	solve(test_case)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	honey = [] + l
	p = list(map(int, input().split()))
	sree = [0] * a
	for e in p:
		sree[e - 1] = 1
	for i in range(a):
		if sree[i] == 0:
			continue
		else:
			j = i
			while j < a and sree[j] != 0:
				j += 1
			shan = l[i:j + 1]
			shan.sort()
			w = 0
			for k in range(i, j + 1):
				l[k] = shan[w]
				w += 1
	honey.sort()
	mps = 0
	for i in range(a):
		if honey[i] != l[i]:
			mps = 1
			break
	if mps:
		print('NO')
	else:
		print('YES')


def swap(arr, i, j):
	temp = arr[i]
	arr[i] = arr[j]
	arr[j] = temp
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	array = list(map(int, input().split()))
	piss = list(map(int, input().split()))
	this = set()
	for i in piss:
		this.add(i - 1)
	flag = True
	for i in range(n):
		if not flag:
			break
		for j in range(n - i - 1):
			if array[j] > array[j + 1]:
				if j not in this:
					flag = False
					break
				swap(array, j, j + 1)
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	sortedA = sorted(a)
	i = 0
	flag = 0
	while i != m:
		if a[p[i] - 1] > a[p[i]]:
			(a[p[i] - 1], a[p[i]]) = (a[p[i]], a[p[i] - 1])
			flag = 1
		i += 1
		if i == m and flag == 1:
			i = 0
			flag = 0
	answer = 'YES'
	for i in range(n):
		if a[i] != sortedA[i]:
			answer = 'NO'
			break
	print(answer)


for i in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	while True:
		x = 0
		for i in p:
			if a[i - 1] > a[i]:
				temp = a[i - 1]
				a[i - 1] = a[i]
				a[i] = temp
				x += 1
		if x == 0:
			break
	y = 0
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			y += 1
	if y == 0:
		print('YES')
	else:
		print('NO')


def main():
	for case in range(int(input())):
		(n, m) = map(int, input().split())
		arr = list(map(int, input().split()))
		pos = list(map(int, input().split()))
		while True:
			ok = True
			for i in pos:
				if i != n and arr[i - 1] > arr[i]:
					(arr[i], arr[i - 1]) = (arr[i - 1], arr[i])
					ok = False
			if ok == True:
				break
		for i in range(1, n):
			if arr[i - 1] > arr[i]:
				print('NO')
				break
		else:
			print('YES')
main()


from collections import Counter
import string
import math
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
testcases = vary(1)
for _ in range(testcases):
	(n, k) = vary(2)
	num = array_int()
	p = array_int()
	p.sort()
	tt = 100
	while tt:
		for i in range(k):
			if num[p[i]] < num[p[i] - 1]:
				(num[p[i]], num[p[i] - 1]) = (num[p[i] - 1], num[p[i]])
		tt -= 1
	if sorted(num) == num:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ch = True
	for i in range(n - 1):
		f = max(a[:n - i])
		g = a.index(f)
		for j in range(g, n - i - 1):
			if ch:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
				if j + 1 not in b and a[j] != a[j + 1]:
					ch = False
					break
	if ch:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = sorted(map(int, input().split()))
	p.append(n + 1)
	(l, r) = (0, 0)
	b = a[0:p[l] - 1]
	while r < m:
		while r < m and p[r] - p[l] == r - l:
			r += 1
		b.extend(sorted(a[p[l] - 1:p[r - 1] + 1]))
		b.extend(a[p[r - 1] + 1:p[r] - 1])
		l = r
	print('YES') if sorted(a) == b else print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(map(int, input().split()))
	c = []
	d = 0
	i = 0
	while i < len(b):
		j = i + 1
		while j < len(b) and b[j] == b[j - 1] + 1:
			j += 1
		while d < b[i] - 1:
			c.append(a[d])
			d += 1
		t = sorted(a[b[i] - 1:b[j - 1] + 1])
		c.extend(t)
		d = len(c)
		i = j
	c.extend(a[d:])
	for i in range(1, n):
		if c[i] < c[i - 1]:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for i in range(t):
	(l, p) = map(int, input().split())
	arr = list(map(int, input().split()))
	res = list(map(int, input().split()))
	dic = {}
	for k in range(l):
		dic[k] = 0
	for k in range(p):
		dic[res[k] - 1] = 1
	check = 0
	for i in range(l - 1):
		swap = True
		for j in range(l - i - 1):
			if arr[j] > arr[j + 1]:
				if dic[j] != 1:
					check = 1
					break
				(arr[j + 1], arr[j]) = (arr[j], arr[j + 1])
				swap = False
		if swap == True or check == 1:
			break
	if check == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for z in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(a)
	p = list(map(int, input().split()))
	while a != b:
		swap = 0
		for i in range(m):
			idx = p[i] - 1
			if a[idx] > a[idx + 1]:
				(a[idx], a[idx + 1]) = (a[idx + 1], a[idx])
				swap += 1
		if swap == 0:
			break
	if a == b:
		print('YES')
	else:
		print('NO')


import copy
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	al = list(map(int, input().split()))
	pl = list(map(int, input().split()))
	asort = copy.deepcopy(al)
	asort.sort()
	pl.sort()
	ans = False
	alc = copy.deepcopy(al)
	while True:
		if al == asort:
			ans = True
			break
		for i in range(n - 1):
			if al[i] > al[i + 1] and i + 1 in pl:
				(al[i], al[i + 1]) = (al[i + 1], al[i])
		if alc == al:
			if al == asort:
				ans = True
				break
			else:
				ans = False
				break
		else:
			alc = copy.deepcopy(al)
	if ans == True:
		print('YES')
	else:
		print('NO')


a = int(input())
for k in range(a):
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	sum = 1
	for j in range(b[0]):
		for k in range(b[0] - 1):
			if c[k] > c[k + 1] and k + 1 in d:
				(c[k], c[k + 1]) = (c[k + 1], c[k])
	for k in range(b[0] - 1):
		if c[k] <= c[k + 1]:
			sum += 1
	if sum == b[0]:
		print('YES')
	else:
		print('NO')


c = int(input())
for i in range(c):
	e = list(map(int, input().split()))
	a = list(map(int, input().split()))
	d = list(map(int, input().split()))
	b = []
	l = 0
	for i in range(len(a) - 1):
		if a[i] <= a[i + 1]:
			l += 1
	if l != len(a):
		for i in range(len(a)):
			for j in range(len(a) - 1):
				if a[j] >= a[j + 1]:
					min = a[j]
					a[j] = a[j + 1]
					a[j + 1] = min
					if a[j] != a[j + 1]:
						b.append(j + 1)
		b = set(b)
		b = list(b)
		k = 0
		for item1 in d:
			if item1 in b:
				k += 1
		if k == len(b):
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


def solve(nums, pos):
	numsInd = [(nums[i], i) for i in range(len(nums))]
	numsInd.sort()
	posSet = set(pos)
	for i in range(len(nums)):
		(_, ind) = numsInd[i]
		doable = all((j + 1 in posSet for j in range(min(ind, i), max(ind, i))))
		if not doable:
			return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	nums = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	print(solve(nums, pos))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = set(map(int, input().split()))
	res = True
	for i in range(1, len(a)):
		for j in range(len(a) - i):
			if a[j] > a[j + 1]:
				if j + 1 in p:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
				else:
					res = False
					break
		else:
			continue
		break
	if res:
		print('YES')
	else:
		print('NO')


import sys
import math
read = lambda : list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	(n, m) = read()
	a = read()
	p = read()
	p.sort()
	p.reverse()
	for num in p:
		for num in p:
			if a[num] < a[num - 1]:
				(a[num], a[num - 1]) = (a[num - 1], a[num])
	ans = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			ans = False
			break
	if ans:
		print('YES')
	else:
		print('NO')


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def prost(x):
	d = math.sqrt(x)
	d = int(d) + 1
	for i in range(2, d):
		if x % i == 0:
			return False
	return True

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def bub():
	f = False
	while not f:
		f = True
		ff = True
		for i in range(len(a) - 1):
			if a[i] > a[i + 1]:
				if i + 1 not in p:
					ff = False
					f = False
				else:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
					f = False
		if not f and (not ff):
			return False
	return True
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	if bub():
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	d = {}
	for i in range(m):
		d[p[i] - 1] = 1
	x = sorted(a)
	f = 0
	while x != a:
		for i in range(n):
			if a[i] != x[i]:
				if i in d or i - 1 in d:
					if a[i] < x[i] and i - 1 in d:
						t = a[i]
						a[i] = a[i - 1]
						a[i - 1] = t
					elif a[i] > x[i] and i in d:
						t = a[i]
						a[i] = a[i + 1]
						a[i + 1] = t
					else:
						f = 1
						break
				else:
					f = 1
					break
		if f == 1:
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split(' ')))
	p = set(map(int, input().split(' ')))
	arr = [i for i in a]
	arr.sort()
	flag = 1
	while a != arr:
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				if not i + 1 in p:
					flag = 0
					break
				else:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
		if not flag:
			break
	if flag:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = set(map(int, input().split()))
	a2 = sorted(a)
	for i in range(len(a)):
		for j in range(len(a) - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if a == a2:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = [int(x) - 1 for x in input().split()]
	s = set(p)
	possible = True
	for i in range(len(arr)):
		mx_idx = i
		for j in range(i + 1, len(arr)):
			if arr[j] < arr[mx_idx]:
				mx_idx = j
		if mx_idx == i:
			continue
		while mx_idx != i:
			if mx_idx - 1 not in p:
				possible = False
				break
			(arr[mx_idx - 1], arr[mx_idx]) = (arr[mx_idx], arr[mx_idx - 1])
			mx_idx -= 1
		if not possible:
			break
	if possible:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = sorted(arr)
	swap = list(map(int, input().split()))
	swap = sorted(swap) + [10 ** 18]
	swaps = []
	pos = 0
	for i in range(m):
		if swap[i] + 1 == swap[i + 1]:
			continue
		else:
			swaps.append([swap[pos], swap[i] + 1])
			pos = i + 1
	for (l, r) in swaps:
		arr = arr[:l - 1] + sorted(arr[l - 1:r]) + arr[r:]
	if arr == ans:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	pos = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	start = p[0]
	for i in range(b - 1):
		if p[i] + 1 == p[i + 1]:
			continue
		else:
			pos[start - 1:p[i] + 1] = sorted(pos[start - 1:p[i] + 1])
			start = p[i + 1]
	pos[start - 1:p[-1] + 1] = sorted(pos[start - 1:p[-1] + 1])
	if pos == sorted(pos):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = sorted(a)
	p = [int(x) for x in input().split()]
	swaps = set(p)
	working = True
	while working:
		working = False
		for i in range(1, n):
			if i in swaps and a[i - 1] > a[i]:
				(a[i - 1], a[i]) = (a[i], a[i - 1])
				working = True
		if a == b:
			print('YES')
			working = False
		elif not working:
			print('NO')


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
from bisect import bisect_left

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(ii()):
	(n, m) = mi()
	a = li()
	p = li()
	c = a.copy()
	c.sort()
	for i in range(m):
		p[i] -= 1
	for j in range(110):
		for i in range(m):
			if p[i] != n - 1 and a[p[i]] > a[p[i] + 1]:
				(a[p[i]], a[p[i] + 1]) = (a[p[i] + 1], a[p[i]])
	if a == c:
		print('YES')
	else:
		print('NO')


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(n, m) = mints()
	a = list(mints())
	p = [1] * 101
	for i in mints():
		p[i] = 0
	cnt = [0] * 101
	for i in range(n):
		cnt[i + 1] = cnt[i] + p[i + 1]
	p = list()
	b = sorted(a)
	where = [[] for i in range(101)]
	for i in range(n - 1, -1, -1):
		where[a[i]].append(i)
	for i in range(n):
		pos = where[b[i]].pop()
		if cnt[pos] - cnt[i] > 0:
			print('NO')
			return
	print('YES')
for i in range(mint()):
	solve()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	karr = list(map(int, input().split()))
	karr = sorted(karr)
	while True:
		flag = False
		for i in karr:
			if i < len(arr) and arr[i - 1] > arr[i] and (i - 1 >= 0):
				(arr[i - 1], arr[i]) = (arr[i], arr[i - 1])
				flag = True
		if not flag:
			break
	prev = arr[0]
	flag = False
	for i in arr[1:]:
		if i < prev:
			flag = True
			break
		prev = i
	print('YES' if not flag else 'NO')


for __ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	ls = l.copy()
	ls.sort()
	l1.sort()
	c = 0
	i = 0
	while i < m:
		if ls == l:
			c += 1
			break
		if l[l1[i] - 1] > l[l1[i]]:
			t = 0
			t = l[l1[i] - 1]
			l[l1[i] - 1] = l[l1[i]]
			l[l1[i]] = t
			i -= 2
			if i < 0:
				i = 0
		else:
			i += 1
	if c == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	nums = list(map(int, input().split()))
	acs = list(map(int, input().split()))
	srt = sorted(nums)
	ok = True
	if nums == srt:
		print('YES')
	else:
		while nums != srt:
			for i in range(n - 1):
				if nums[i] > nums[i + 1] and i + 1 in acs:
					(nums[i], nums[i + 1]) = (nums[i + 1], nums[i])
				elif nums[i] > nums[i + 1] and i + 1 not in acs:
					ok = False
					break
			if not ok:
				break
		if ok:
			print('YES')
		else:
			print('NO')


from collections import defaultdict
for _ in range(int(input())):
	(N, M) = map(int, input().split())
	L = list(map(int, input().split()))
	A = list(map(int, input().split()))
	X = L.copy()
	X.sort()
	FLAG = 0
	Hash = defaultdict(lambda : 0)
	for i in A:
		Hash[i] = 1
	for i in range(N - 1):
		for j in range(N - i - 1):
			if L[j + 1] < L[j]:
				if Hash[j + 1] == 0:
					FLAG = 1
					break
				else:
					(L[j], L[j + 1]) = (L[j + 1], L[j])
	if FLAG == 1:
		print('NO')
	elif X == L:
		print('YES')
	else:
		print('NO')


import sys
import math

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

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def main(tc: int):
	(n, m) = mp()
	a = ria()
	p = ria()
	c = [0] * n
	l = 0
	for i in p:
		c[i - 1] = 1
	for i in range(n):
		if c[i] == 0:
			a[l:i + 1] = sorted(a[l:i + 1])
			l = i + 1
	for i in range(1, n):
		if a[i - 1] > a[i]:
			ws('NO')
			return
	ws('YES')
t = ri()
for tc in range(1, t + 1):
	main(tc)


import sys
n = int(input())
for i in range(n):
	(m, p) = map(int, input().strip().split())
	a = []
	arr = [int(i) for i in input().strip().split()]
	for (idx, v) in enumerate(arr):
		a.append((v, idx))
	a = sorted(a)
	b = []
	for (idx, v) in enumerate(a):
		if idx <= v[1]:
			b.append((idx, v[1]))
		else:
			b.append((v[1], idx))
	b = sorted(b)
	pos = [int(i) for i in input().strip().split()]
	e = -1
	res = 'YES'
	for v in b:
		if v[0] != v[1]:
			s = max(e, v[0])
			if s <= v[1] - 1:
				if any((i + 1 not in pos for i in range(s, v[1]))):
					res = 'NO'
					break
				e = v[1]
	print(res)


from os import path
from sys import stdin, stdout
maxn = 105
if path.exists('inp.txt'):
	stdin = open('inp.txt', 'r')
a = [0 for i in range(maxn)]
p = [0 for i in range(maxn)]
q = int(stdin.readline())
for _ in range(q):
	(n, m) = map(int, stdin.readline().split())
	a[1:] = list(map(int, stdin.readline().split()))
	p[1:] = list(map(int, stdin.readline().split()))
	while True:
		check = 0
		for i in range(1, m + 1):
			if a[p[i]] > a[p[i] + 1]:
				(a[p[i]], a[p[i] + 1]) = (a[p[i] + 1], a[p[i]])
				check = 1
		if not check:
			break
	check = 1
	for i in range(1, n):
		if a[i] > a[i + 1]:
			check = 0
	print('YES' if check else 'NO')


t = int(input())
while t:
	t -= 1
	nm = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	(l, r, s) = ([0] * len(a), [0] * len(a), [False] * len(a))
	for i in p:
		s[i - 1] = True
	(l[0], r[-1]) = (0, len(a) - 1)
	for i in range(1, len(a)):
		l[i] = l[i - 1] if s[i - 1] else i
	for i in range(len(a) - 2, -1, -1):
		r[i] = r[i + 1] if s[i] else i
	x = [(a[i], i) for i in range(len(a))]
	x.sort()
	res = True
	for i in range(len(x)):
		p = x[i]
		if p[1] > i:
			res = l[p[1]] <= i
		else:
			res = r[p[1]] >= i
		if res == False:
			break
	print('YES' if res else 'NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	aa = a
	p.sort()
	tem1 = 0
	tem2 = 0
	for j in range(len(p)):
		if p[j] != p[tem1] + tem2:
			aa[p[tem1] - 1:p[j - 1] + 1] = sorted(aa[p[tem1] - 1:p[j - 1] + 1])
			tem1 = j
			tem2 = 0
		tem2 += 1
	aa[p[tem1] - 1:p[j] + 1] = sorted(aa[p[tem1] - 1:p[j] + 1])
	if aa == sorted(a):
		print('YES')
	else:
		print('NO')


import math
from math import sqrt
import sys
from functools import reduce
from collections import defaultdict

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def modInverse(a, m):
	g = gcd(a, m)
	if g != 1:
		return 0
	else:
		return power(a, m - 2, m)

def power(x, y, m):
	if y == 0:
		return 1
	p = power(x, y // 2, m) % m
	p = p * p % m
	if y % 2 == 0:
		return p
	else:
		return x * p % m

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def solve_final(g, suitable, n):
	comb = 0
	distance = defaultdict(dict)
	for i in range(1, n + 1):
		if suitable[i] == 0:
			continue
		visited = [False] * (n + 1)
		queue = [i]
		visited[i] = True
		k = 1
		while len(queue) != 0:
			distance[i][k] = []
			temp = []
			for _ in range(len(queue)):
				node = queue.pop(0)
				for nd in g[node]:
					if not visited[nd]:
						temp.append(nd)
						if suitable[nd] == 1:
							distance[i][k].append(nd)
						visited[nd] = True
			k += 1
			queue = temp
	print(distance)
	for i in range(1, n + 1):
		for dist in distance[i]:
			for nd1 in distance[i][dist]:
				for nd2 in distance[nd1][dist]:
					if nd2 in distance[i][dist]:
						print(i, nd1, nd2)
						comb += 1
	return comb

def solve(a, b):
	if a == b:
		return 0
	if b > a:
		if a % 2 and b % 2:
			return 2
		elif a % 2 or b % 2:
			return 1
		else:
			return 2
	elif a % 2 and b % 2:
		return 1
	elif a % 2 or b % 2:
		return 2
	else:
		return 1

def isthere(a, b):
	print(a, b)
	try:
		idx = b.index(a[0])
		l = len(a)
		if idx + l <= len(b):
			return b[idx:idx + l] == a
		return False
	except ValueError:
		print(a, b, 'e')
		return False
for _ in range(iinput()):
	(n, m) = rinput()
	a = rlinput()
	p = sorted(rlinput())
	flag = True
	while flag:
		temp = False
		for i in range(m):
			idx = p[i]
			if a[idx] < a[idx - 1]:
				(a[idx], a[idx - 1]) = (a[idx - 1], a[idx])
				temp = True
		flag = temp
	print('YES' if a == sorted(a) else 'NO')


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	flag = True
	for i in range(0, n):
		for j in range(0, n - 1 - i):
			if a[j + 1] < a[j]:
				if j + 1 in p:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
				else:
					flag = False
					break
		if not flag:
			break
	if flag:
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(lambda x: int(x) - 1, input().split()))
	change = True
	while change:
		change = False
		for idx in p:
			if a[idx] > a[idx + 1]:
				temp = a[idx + 1]
				a[idx + 1] = a[idx]
				a[idx] = temp
				change = True
	prev = a[0]
	for i in range(1, len(a)):
		if a[i] < prev:
			print('NO')
			break
		prev = a[i]
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	nn = list(map(int, input().split()))
	mm = list(map(int, input().split()))
	flag = True
	for i in range(n):
		for j in range(0, n - i - 1):
			if nn[j] > nn[j + 1]:
				if j + 1 in mm:
					(nn[j], nn[j + 1]) = (nn[j + 1], nn[j])
				else:
					flag = False
					break
		if flag:
			pass
		else:
			break
	if flag:
		print('YES')
	else:
		print('NO')


I = input
for _ in [0] * int(I()):
	(n, m) = map(int, I().split())
	a = list(map(int, I().split()))
	p = sorted(list(map(int, I().split())))
	for i in range(n):
		for j in p:
			(a[j - 1], a[j]) = sorted(a[j - 1:j + 1])
	print(['NO', 'YES'][a == sorted(a)])


tc = int(input())
for _ in range(tc):
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	pss = list(map(int, input().split()))
	while True:
		swapped = False
		for i in pss:
			i = i - 1
			if i + 1 < len(arr) and arr[i] > arr[i + 1]:
				temp = arr[i]
				arr[i] = arr[i + 1]
				arr[i + 1] = temp
				swapped = True
		if swapped == False:
			break
	srted = sorted(arr)
	if srted == arr:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	s = sorted(l)
	for j in range(n):
		if s == l:
			break
		for k in range(m):
			index = p[k]
			if l[index] < l[index - 1]:
				(l[index - 1], l[index]) = (l[index], l[index - 1])
	if s == l:
		print('YES')
	else:
		print('NO')


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	dc = [0] * (n - 1)
	temp = list()
	for i in range(m):
		dc[p[i] - 1] += 1
	st = 0
	for i in range(len(dc)):
		if dc[i] == 0:
			curr = arr[st:i + 1]
			curr.sort()
			for j in range(len(curr)):
				temp.append(curr[j])
			st = i + 1
	curr = arr[st:n]
	curr.sort()
	for j in range(len(curr)):
		temp.append(curr[j])
	arr.sort()
	flag = 0
	for i in range(len(arr)):
		if arr[i] != temp[i]:
			flag = 1
	if flag:
		print('NO')
	else:
		print('YES')


from __future__ import division, print_function

def get_ints():
	return map(int, input().strip().split())

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

def main():
	for _ in range(int(input())):
		(n, m) = get_ints()
		arr = get_array()
		p = get_array()
		c = sorted(arr)
		for i in range(n):
			for j in range(m):
				if p[j] != n:
					if arr[p[j] - 1] > arr[p[j]]:
						(arr[p[j] - 1], arr[p[j]]) = (arr[p[j]], arr[p[j] - 1])
		if arr == c:
			print('YES')
		else:
			print('NO')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]

class UnionFind:

	def __init__(self, n):
		self.n = n
		self.parents = [-1] * n

	def root(self, x):
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.root(self.parents[x])
			return self.parents[x]

	def unite(self, x, y):
		x = self.root(x)
		y = self.root(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

	def size(self, x):
		return -self.parents[self.root(x)]

	def is_same(self, x, y):
		return self.root(x) == self.root(y)

def solve():
	(n, m) = Scanner.map_int()
	a = Scanner.map_int()
	p = Scanner.map_int()
	p = [x - 1 for x in p]
	uni = UnionFind(n)
	for x in p:
		uni.unite(x, x + 1)
	b = sorted(a)
	ls = defaultdict(list)
	for (i, x) in enumerate(a):
		heapq.heappush(ls[uni.root(i)], x)
	ans = [0 for _ in range(n)]
	for i in range(n):
		ans[i] = heapq.heappop(ls[uni.root(i)])
	print('YNEOS'[not ans == b::2])

def main():
	T = Scanner.int()
	for _ in range(T):
		solve()
main()


def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		arr = list(map(int, input().split()))
		swap_arr = set(map(int, input().split()))
		temp_arr = []
		temp_temp_arr = []
		for i in range(n):
			temp_temp_arr.append(arr[i])
			if not i + 1 in swap_arr or i == n - 1:
				temp_arr.append(temp_temp_arr)
				temp_temp_arr = []
		final_arr = []
		for temp_temp_arr in temp_arr:
			final_arr.extend(sorted(temp_temp_arr))
		if final_arr == list(sorted(arr)):
			print('YES')
		else:
			print('NO')
main()


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	try:
		for _ in range(inp()):
			(n, m) = invr()
			a = inlt()
			p = inlt()
			a1 = sorted(a)
			f = True
			while f:
				c = 0
				for i in range(1, n):
					if a[i] < a[i - 1] and i in p:
						c += 1
						(a[i], a[i - 1]) = (a[i - 1], a[i])
				if c == 0:
					f = False
			if a1 == a:
				print('YES')
			else:
				print('NO')
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	k = list(sorted(a))[:]
	p = list(map(int, input().split()))
	for i in range(n):
		if i + 1 not in p:
			if list(sorted(a[0:i + 1])) != k[0:i + 1]:
				print('NO')
				break
	else:
		print('YES')


caseNum = int(input())
for i in range(caseNum):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	p = [i - 1 for i in p]
	p.sort()
	ans = 1
	p_start = p[0]
	p_end = p_start + 1
	for j in range(len(p)):
		if j + 1 == len(p):
			a[p_start:p_end + 1] = sorted(a[p_start:p_end + 1])
		elif p[j + 1] - p[j] == 1:
			p_end = p[j + 1] + 1
		elif p[j + 1] - p[j] > 1:
			a[p_start:p_end + 1] = sorted(a[p_start:p_end + 1])
			p_start = p[j + 1]
			p_end = p_start + 1
	for k in range(len(a) - 1):
		if a[k] > a[k + 1]:
			ans = 0
			break
	if ans == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, p) = map(int, input().split())
	s = list(map(int, input().split()))
	sp = sorted(list(map(int, input().split())))
	sor_s = sorted(s)
	pos = 1
	x = 1
	for i in range(p):
		if i != p - 1 and sp[i + 1] - sp[i] == 1:
			x += 1
		elif i == p - 1 and sp[i] - sp[i - 1] != 1 and (sp[i] != n - 1):
			s[sp[i] - x:sp[i] + 1] = sorted(s[sp[i] - x:sp[i] + 1])
		else:
			s[sp[i] - x:sp[i] + 1] = sorted(s[sp[i] - x:sp[i] + 1])
			x = 1
	for j in range(n):
		if s[j] != sor_s[j]:
			print('NO')
			pos = 0
			break
	if pos:
		print('YES')


for tin in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for _ in range(len(b)):
		b[_] = b[_] - 1
	b.sort()
	c = 0
	k = 0
	i = 0
	while i < m:
		if a[b[i]] > a[b[i] + 1]:
			(a[b[i]], a[b[i] + 1]) = (a[b[i] + 1], a[b[i]])
		else:
			c += 1
		if i == m - 1:
			if c == m:
				break
			else:
				c = 0
				i = 0
		else:
			i += 1
	for _ in range(n - 1):
		if a[_] > a[_ + 1]:
			k += 1
			break
	if k == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = set(list(map(int, input().split())))
	for i in range(n):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	pos = sorted(map(lambda x: int(x) - 1, input().split())) + [10 ** 9]
	ans = sorted(a)
	l = pos[0]
	for i in range(m):
		if pos[i] + 1 < pos[i + 1]:
			a[l:pos[i] + 2] = sorted(a[l:pos[i] + 2])
			l = pos[i + 1]
	if a == ans:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(p, q) = map(int, input().split())
	l = list(map(int, input().split()))
	r = sorted(l)
	s = list(map(int, input().split()))
	c = 0
	t = 0
	while c < 1:
		for i in range(p - 1):
			if l[i + 1] < l[i]:
				if i + 1 in s:
					temp = l[i]
					l[i] = l[i + 1]
					l[i + 1] = temp
				else:
					t += 1
					c += 1
					break
		if r == l:
			c += 1
			break
	if c == 1 and t == 0:
		print('YES')
	else:
		print('NO')


numTest = int(input())
for test in range(numTest):
	(n, m) = map(int, input().split())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	dd = {}
	for x in b:
		dd[x] = 1
	for step in range(n):
		for i in range(n - 1):
			if dd.get(i + 1) == 1 and a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
	if sorted(a) == a:
		print('YES')
	else:
		print('NO')


import math

def main_function():
	test_cases = range(int(input()))
	for test_case in test_cases:
		(n, m) = [int(i) for i in input().split(' ')]
		a = [int(i) for i in input().split(' ')]
		p = sorted([int(i) - 1 for i in input().split(' ')])
		positions = [i for i in range(n)]
		for i in p:
			positions[i + 1] = positions[i]
		new_a = [[a[i], positions[i]] for i in range(n)]
		if sorted(new_a, key=lambda x: x[0]) == sorted(new_a, key=lambda x: (x[1], x[0])):
			print('YES')
		else:
			print('NO')
main_function()


def solve(n, m, a, p):

	def is_sorted(alist):
		for i in range(len(alist) - 1):
			if alist[i] > alist[i + 1]:
				return False
		return True
	is_continue = True
	while is_continue:
		num_ops = 0
		for pos in p:
			if a[pos - 1] > a[pos]:
				num_ops += 1
				(a[pos - 1], a[pos]) = (a[pos], a[pos - 1])
		if is_sorted(a):
			return True
		elif num_ops == 0:
			return False
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	result = 'YES' if solve(n, m, a, p) else 'NO'
	print(result)


t = int(input())
while t > 0:
	t = t - 1
	s1 = input()
	s2 = input()
	l = s2.split()
	s3 = input()
	l2 = s3.split()
	for i in range(0, len(l2)):
		l2[i] = int(l2[i])
	flag = 1
	for i in range(0, len(l)):
		for j in range(0, len(l) - i - 1):
			if int(l[j]) > int(l[j + 1]) and j + 1 in l2:
				(l[j], l[j + 1]) = (l[j + 1], l[j])
			if int(l[j]) > int(l[j + 1]) and j + 1 not in l2:
				flag = 0
	if flag == 1:
		print('YES')
	else:
		print('NO')


class Solution:

	def solve(self, n, m, arr, p):
		p.sort()
		i = 0
		j = 0
		while i < m:
			while j < m and p[j] - p[i] == j - i:
				j += 1
			arr[p[i] - 1:p[j - 1] + 1] = sorted(arr[p[i] - 1:p[j - 1] + 1])
			i = j
		for i in range(n - 1):
			if arr[i] > arr[i + 1]:
				return False
		return True
sol = Solution()
t = int(input().strip())
for i in range(t):
	[n, m] = list(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	p = list(map(int, input().strip().split()))
	print('YES' if sol.solve(n, m, arr, p) else 'NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	an = list(map(int, input().split()))
	san = sorted(an)
	am = sorted(list(map(int, input().split())))
	am = [i - 1 for i in am]
	l = []
	i = 0
	while i < m:
		temp = am[i]
		c = am[i] + 1
		i += 1
		while i < m and am[i] == c:
			c += 1
			i += 1
		l.append([temp, c])
	for k in l:
		(i, j) = k
		if j == n:
			j -= 1
		an = an[:i] + sorted(an[i:j + 1]) + an[j + 1:]
	if an == san:
		print('YES')
	else:
		print('NO')


def solve(n, m, a, p):
	a = [[v, i + 1] for (i, v) in enumerate(a)]
	a.sort()
	for i in range(n):
		(v, k) = a[i]
		(l, r) = (i + 1, k)
		if l > r:
			(l, r) = (r, l)
		for j in range(l, r):
			if j not in p:
				return 'NO'
	return 'YES'

def main():
	inp = lambda : [int(x) for x in input().split()]
	tc = int(input())
	for _ in range(tc):
		(n, m) = inp()
		a = inp()
		p = inp()
		print(solve(n, m, a, p))
main()


cases = int(input())
for t in range(cases):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = sorted(list(map(int, input().split())))
	a = [(v, i) for (i, v) in enumerate(a)]
	p = set([(i - 1, i) for i in p])
	a = sorted(a)
	f = 0
	for i in range(n):
		(v, pos) = a[i]
		spos = min(i, pos)
		epos = max(i, pos)
		posset = set([(j, j + 1) for j in range(spos, epos)])
		if posset - p:
			print('NO')
			f = 1
			break
	if f == 0:
		print('YES')


t = int(input())
while t > 0:
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	p.sort()
	l = p[0] - 1
	for i in range(1, m):
		if p[i] - p[i - 1] > 1:
			r = p[i - 1] + 1
			a[l:r] = sorted(a[l:r])
			l = p[i] - 1
	r = p[m - 1] + 1
	a[l:r] = sorted(a[l:r])
	flag = 0
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			flag = 1
	if flag == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


from collections import defaultdict as dd
t = int(input())
while t:
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	lol = 0
	for j in range(n):
		for i in range(1, n - j):
			if l[i] < l[i - 1]:
				if i not in p:
					lol = 1
					break
				else:
					(l[i], l[i - 1]) = (l[i - 1], l[i])
	if lol:
		print('NO')
	else:
		print('YES')
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 1
	while True:
		flag = 1
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				if i + 1 in b:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
					flag = 0
				else:
					flag = 1
					ans = 0
					break
		if flag == 1:
			break
	if ans == 0:
		print('NO')
	else:
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				print('NO')
				break
		else:
			print('YES')


t = int(input())
for i in range(t):
	(n, m) = [int(k) for k in input().split()]
	w = [int(k) for k in input().split()]
	zxc = sorted(w)
	q = sorted([int(k) for k in input().split()])
	new = []
	asd = set()
	c = [q[0], q[0]]
	asd |= {q[0]}
	for j in q[1:]:
		asd |= {j}
		if j == c[1] + 1:
			c = [c[0], c[1] + 1]
		else:
			new.append([c[0], c[1] + 1])
			asd |= {c[1] + 1}
			c = [j, j]
	new.append([c[0], c[1] + 1])
	asd |= {c[1] + 1}
	counter = 0
	for k in range(n):
		if k + 1 not in asd:
			if w[k] != zxc[k]:
				counter = 1
				break
	for k in new:
		if sorted(w[k[0] - 1:k[1]]) != zxc[k[0] - 1:k[1]]:
			counter = 1
			break
	if counter:
		print('NO')
	else:
		print('YES')


def isSorted(A, n):
	isSorted = True
	for i in range(0, n - 1):
		if A[i] > A[i + 1]:
			isSorted = False
			break
	if isSorted:
		return True
	return False

def solve():
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	P = list(map(lambda x: int(x) - 1, input().split()))
	if isSorted(A, n):
		return True
	canMove = True
	while canMove:
		canMove = False
		for p in P:
			if A[p] > A[p + 1]:
				(A[p], A[p + 1]) = (A[p + 1], A[p])
				canMove = True
		if isSorted(A, n):
			return True
	return False
t = int(input())
for _ in range(t):
	print('YES' if solve() else 'NO')


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p = [i - 1 for i in p]
	p_s = set(p)
	ok = True
	for i in range(n):
		cur_min = a[i]
		min_ind = i
		for j in range(i + 1, n):
			if a[j] < cur_min:
				cur_min = a[j]
				min_ind = j
		for j in range(min_ind, i, -1):
			if j - 1 not in p_s:
				ok = False
				print('NO')
				break
			else:
				(a[j], a[j - 1]) = (a[j - 1], a[j])
		if not ok:
			break
	if ok:
		print('YES')


t = int(input())
while t > 0:
	(n, m) = [int(x) for x in input().split()]
	array = [int(x) for x in input().split()]
	swapAllowed = [False] * n
	temp = [int(x) for x in input().split()]
	for x in temp:
		swapAllowed[x - 1] = True
	(i, j) = (0, 0)
	while i < n:
		isWhite = True if swapAllowed[i] else False
		while j < n and swapAllowed[i] == swapAllowed[j]:
			j += 1
		last = min(j + 1, n)
		if isWhite:
			array[i:last] = sorted(array[i:last])
		i = j
	Ans = 'YES'
	for i in range(n - 1):
		if array[i] > array[i + 1]:
			Ans = 'NO'
			break
	print(Ans)
	t -= 1


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
sys.setrecursionlimit(10 ** 5)

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

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

def li():
	return list(map(int, sys.stdin.readline().split()))
print = sys.stdout.write

def solve():
	(n, m) = mi()
	l1 = li()
	o = li()
	l2 = sorted(l1)
	if l1 == l2 or m + 1 >= n:
		print('YES\n')
	else:
		l3 = []
		[l3.append(x - 1) for x in o]
		flag = True
		while flag == True:
			count = 0
			for _ in l3:
				if l1[_] > l1[_ + 1]:
					(l1[_], l1[_ + 1]) = (l1[_ + 1], l1[_])
					count += 1
			if count > 0:
				continue
			else:
				flag = False
		if l1 == l2:
			print('YES\n')
		else:
			print('NO\n')
for _ in range(ii()):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	pos = set([int(x) - 1 for x in input().split()])

	def giveIndexMinMax(index):
		(mini, maxi) = (arr[index], arr[index])
		for index in range(index, len(arr)):
			mini = min(mini, arr[index])
			maxi = max(maxi, arr[index])
			if index not in pos:
				break
		return [mini, maxi, index]
	prevMax = 0
	index = 0
	flag = False
	while index < len(arr):
		if index in pos:
			(mini, maxi, index) = giveIndexMinMax(index)
			if mini >= prevMax:
				prevMax = maxi
			else:
				flag = True
				print('NO')
				break
		else:
			if arr[index] < prevMax:
				flag = True
				print('NO')
				break
			prevMax = arr[index]
		index += 1
	if not flag:
		print('YES')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for it in range(n):
		for j in range(1, n):
			if j in p and a[j - 1] > a[j]:
				(a[j - 1], a[j]) = (a[j], a[j - 1])
	b = sorted(a)
	if a == b:
		print('YES')
	else:
		print('NO')


import sys
import bisect

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	(n, m) = rl()
	a = rl()
	p = [int(x) - 1 for x in input().split()]
	p.sort()
	for i in range(len(p)):
		for j in range(len(p)):
			if a[p[j]] > a[p[j] + 1]:
				temp = a[p[j]]
				a[p[j]] = a[p[j] + 1]
				a[p[j] + 1] = temp
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


from sys import *
input = stdin.readline
import random
from bisect import *
import math
from collections import *
import operator
from heapq import *
from itertools import *
inf = 10 ** 18
mod = 10 ** 9 + 7

def check(x):
	if x in p:
		return True
	return False
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = set(map(int, input().split()))
	for i in range(n):
		for j in range(n - 1):
			if a[j] > a[j + 1] and check(j + 1):
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	mass = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	do = True
	while do:
		do = False
		for j in range(1, n):
			if mass[j - 1] > mass[j] and j in arr:
				do = True
				(mass[j], mass[j - 1]) = (mass[j - 1], mass[j])
	f = False
	for j in range(1, n):
		if mass[j - 1] > mass[j]:
			f = True
			break
	if f:
		print('NO')
	else:
		print('YES')


import os
import sys
from io import BytesIO, IOBase
import threading
from math import cos, sin, pi
mod = 998244353

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		a.insert(0, -1)
		arr = a.copy()
		arr.sort()
		b = list(map(int, input().split()))
		b.sort()
		i = 0
		while i < 10001:
			pos = b[i % m]
			if a[pos + 1] < a[pos]:
				(a[pos + 1], a[pos]) = (a[pos], a[pos + 1])
			i += 1
		if a == arr:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for f in range(t):
	boo = True
	(n, m) = map(int, input().split())
	a = [int(s) for s in input().split()]
	p = [int(s) for s in input().split()]
	arr = [0 for i in range(n)]
	for i in range(m):
		arr[p[i]] = 1
	for i in range(n - 1):
		for j in range(n - i - 1):
			if a[j] > a[j + 1]:
				if arr[j + 1] == 1:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
				else:
					boo = False
					break
		if boo == False:
			break
	if boo == False:
		print('NO')
	else:
		print('YES')


t = int(input())
result = []
for _ in range(t):
	[n, m] = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	p = sorted(list(map(int, input().split(' '))))
	check = ''
	for _ in range(n):
		for k in p:
			if arr[k - 1] > arr[k]:
				tmp = arr[k - 1]
				arr[k - 1] = arr[k]
				arr[k] = tmp
	if sorted(arr) == arr:
		check = 'YES'
	else:
		check = 'NO'
	result.append(check)
for item in result:
	print(item)


k = int(input())
for i123 in range(k):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	a_sorted = sorted(a)
	for i in range(n):
		for j in p:
			if a[j - 1] > a[j]:
				(a[j - 1], a[j]) = (a[j], a[j - 1])
	if a == a_sorted:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	B.sort()
	(ma, m1, ma1, i, l) = (0, 0, 0, 0, 0)
	f = True
	f1 = False
	while i < n and f:
		if i + 1 != B[l]:
			if f1:
				if A[i] < m1:
					m1 = A[i]
				if A[i] > ma1:
					ma1 = A[i]
				if m1 < ma:
					f = False
				ma = ma1
				m1 = ma
			elif A[i] < ma:
				f = False
			else:
				ma = A[i]
				m1 = A[i]
				ma1 = A[i]
			f1 = False
		else:
			if not f1:
				if m1 < ma:
					f = False
				ma = ma1
				m1 = 101
				ma1 = 0
			if A[i] > ma1:
				ma1 = A[i]
			if A[i] < m1:
				m1 = A[i]
			f1 = True
			if l + 1 < m:
				l += 1
		i += 1
	if m1 < ma:
		f = False
	if f:
		print('YES')
	else:
		print('NO')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = set(list(map(int, input().split())))
	for i in range(n):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


def solve():
	(n, m) = map(int, input().split())
	array = list(map(int, input().split()))
	copy = array[:]
	ps = list(sorted(map(int, input().split())))
	can = []
	left = ps[0]
	right = left + 1
	for index in range(1, m):
		if ps[index] - ps[index - 1] == 1 or ps[index] == 1:
			right += 1
		else:
			can.append((left, right))
			left = ps[index]
			right = left + 1
	can.append((left, right))
	for each in can:
		array[each[0] - 1:each[1]] = sorted(array[each[0] - 1:each[1]])
	if array == sorted(copy):
		print('YES')
	else:
		print('NO')
T = int(input())
for _ in range(T):
	solve()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	p.sort()
	for i in range(len(a)):
		for k in p:
			k -= 1
			if a[k] > a[k + 1]:
				temp = a[k]
				a[k] = a[k + 1]
				a[k + 1] = temp
	check = True
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			check = False
	if check:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	array1 = list(map(int, input().split()))
	position = list(map(int, input().split()))
	flag = True
	for i in range(n):
		for j in range(m):
			if array1[position[j] - 1] > array1[position[j]]:
				temp1 = array1[position[j] - 1]
				temp2 = array1[position[j]]
				array1[position[j] - 1] = temp2
				array1[position[j]] = temp1
	for i in range(n - 1):
		if array1[i + 1] < array1[i]:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()

def is_sorted(L):
	for i in range(1, len(L)):
		if L[i] < L[i - 1]:
			return False
	return True

def main():
	T = int(rl())
	for _ in range(T):
		(n, m) = (int(x) for x in rll())
		A = [int(x) for x in rll()]
		P = [int(x) - 1 for x in rll()]
		P.sort()
		(curr_run, runs) = ([], [])
		for (i, pos) in enumerate(P):
			if len(curr_run) == 0:
				curr_run.append(pos)
			elif curr_run[-1] == pos - 1:
				curr_run.append(pos)
			else:
				if curr_run[-1] <= n - 2:
					curr_run.append(curr_run[-1] + 1)
				runs.append(curr_run)
				curr_run = [pos]
		if len(curr_run) > 0:
			if curr_run[-1] <= n - 2:
				curr_run.append(curr_run[-1] + 1)
			runs.append(curr_run)
		preve = 0
		pieces = []
		for run in runs:
			(s, e) = (run[0], run[-1])
			pieces.append(A[preve + 1 if preve > 0 else 0:s])
			pieces.append(sorted(A[s:e + 1]))
			preve = e
		pieces.append(A[preve + 1:])
		flattened = [x for subL in pieces for x in subL]
		if is_sorted(flattened):
			stdout.write('YES')
			stdout.write('\n')
		else:
			stdout.write('NO')
			stdout.write('\n')
	stdout.close()
main()


from sys import stdin
import math

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, m) = [int(x) for x in inp().split()]
	ar = [int(x) for x in inp().split()]
	p = [int(x) for x in inp().split()]
	flag = False
	for i in range(n):
		if i > 0:
			if ar[i] < ar[i - 1]:
				c = i
				while True:
					if ar[c] >= ar[c - 1] or c == 0:
						break
					elif c in p:
						swap = ar[c]
						ar[c] = ar[c - 1]
						ar[c - 1] = swap
						c -= 1
					else:
						print('NO')
						flag = True
						break
		if flag:
			break
	if flag:
		continue
	else:
		print('YES')


t = int(input())
for cid in range(t):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	start = -1
	last = 69696969696
	for j in p:
		i = j - 1
		if start == -1:
			start = i
			last = i
		if i > last + 1:
			A[start:i] = sorted(A[start:i])
			start = i
		last = i
	A[start:min(n, last + 2)] = sorted(A[start:min(n, last + 2)])
	if sorted(A) == A:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
inp = stdin.readline
say = stdout.write

def main():
	for _ in range(int(inp().strip())):
		s = []
		(n, m) = [int(__) for __ in inp().strip().split()]
		arr = [int(__) for __ in inp().strip().split()]
		s = '%s' % ','.join([str(t) for t in arr])
		pos = [int(__) for __ in inp().strip().split()]
		print(StupidSort(n, m, arr, pos))

def getSorted(alist):
	alist.sort()
	return alist

def StupidSort(n, m, arr, pos):
	for i in range(n):
		for j in pos:
			if arr[j - 1] > arr[j]:
				temp = arr[j - 1]
				arr[j - 1] = arr[j]
				arr[j] = temp
			if arr == getSorted(list(arr)):
				return 'YES'
	return 'NO'
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	p = set(map(int, input().split()))
	l1 = list(l)
	l1.sort()
	f = 0
	while True:
		if f == 1:
			break
		for x in range(a - 1):
			if l[x] > l[x + 1] and x + 1 in p:
				(l[x], l[x + 1]) = (l[x + 1], l[x])
				break
		else:
			f = 1
	if l == l1:
		print('YES')
	else:
		print('NO')


def srtd(p0, p1, lisa):
	c = lisa[p0 - 1:p1]
	c.sort()
	for (i, v) in enumerate(c, p0 - 1):
		lisa[i] = v

def foo():
	(a, p) = list(map(int, input().split()))
	lisa = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	i = 1
	p0 = p[0]
	p1 = p[0] + 1
	while i < len(p):
		if p[i] == p1:
			p1 = p[i] + 1
		else:
			srtd(p0, p1, lisa)
			p0 = p[i]
			p1 = p[i] + 1
		i += 1
	srtd(p0, p1, lisa)
	c = True
	for (i, v) in enumerate(lisa[1:], 1):
		if lisa[i - 1] > lisa[i]:
			c = False
	if c:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	foo()


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	n = inp()
	for i in range(n):
		[n, m] = inlt()
		a = inlt()
		p = inlt()
		p.sort()
		j = 0
		while j < len(p):
			start = p[j]
			end = start + 1
			j = j + 1
			while j < len(p):
				if p[j] != end:
					break
				j = j + 1
				end = end + 1
			start = start - 1
			end = end - 1
			dum = a[start:min(len(a), end + 1)]
			dum.sort()
			a[start:min(len(a), end + 1)] = dum
		is_possible = 'YES'
		for j in range(1, len(a)):
			if a[j - 1] > a[j]:
				is_possible = 'NO'
				break
		print(is_possible)
	return
main()


def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p = set(p)
	for i in range(1, len(a)):
		if a[i - 1] > a[i]:
			k = i
			while k != 0 and a[k - 1] > a[k]:
				if k not in p:
					print('NO')
					return
				else:
					r = a[k - 1]
					a[k - 1] = a[k]
					a[k] = r
					k -= 1
	print('YES')
t = int(input())
for i in range(t):
	main()


import math

def rints():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(n, m) = rints()
	a = rints()
	p = rints()
	for _ in range(100):
		for pi in p:
			if a[pi - 1] > a[pi]:
				(a[pi], a[pi - 1]) = (a[pi - 1], a[pi])
	print('YES' if sorted(a[:]) == a else 'NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, m) = LI()
		a = LI()
		p = LI_()
		p.sort()
		l = p[0]
		r = p[0] + 1
		for c in p[1:]:
			if c == r:
				r += 1
			else:
				a[l:r + 1] = sorted(a[l:r + 1])
				l = c
				r = c + 1
		a[l:r + 1] = sorted(a[l:r + 1])
		rr.append(YES(sorted(a) == a))
	return JA(rr, '\n')
print(main())


for _ in [0] * int(input()):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = sorted(a)
	k = 0
	j = 0
	while a != c:
		j = k
		for i in p:
			if a[i - 1] > a[i]:
				(a[i - 1], a[i]) = (a[i], a[i - 1])
				k += 1
		if j == k:
			break
	if a != c:
		print('NO')
	else:
		print('YES')


def main(n, m, a, p):
	c = 0
	if m == n - 1:
		return 'YES'
	for i in range(n - 1):
		if a[i] <= a[i + 1]:
			c += 1
	if c == n - 1:
		return 'YES'
	for i in range(n - 1):
		for j in range(n - 1):
			if a[j] > a[j + 1]:
				if j + 1 in p:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
				else:
					return 'NO'
	return 'YES'
k = int(input())
for _ in range(k):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	print(main(n, m, a, p))


t = int(input())
for i in range(t):
	a = input().split()
	for i in range(len(a)):
		a[i] = int(a[i])
	arr = input().split()
	for i in range(len(arr)):
		arr[i] = int(arr[i])
	p = input().split()
	for i in range(len(p)):
		p[i] = int(p[i])
	chance = 1
	while chance == 1:
		temparr = []
		for i in range(len(arr)):
			temparr += [arr[i]]
		for i in range(len(arr) - 1):
			if arr[i] > arr[i + 1] and i + 1 in p:
				temp = arr[i]
				arr[i] = arr[i + 1]
				arr[i + 1] = temp
		if temparr == arr:
			chance = 0
	flag = 1
	for i in range(len(arr) - 1):
		if arr[i] > arr[i + 1]:
			flag = 0
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


for q in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	seen = dict()
	for i in p:
		seen[i] = 1
	res = 'YES'
	for i in range(n - 1):
		for j in range(n - i - 1):
			if a[j] > a[j + 1]:
				if seen.get(j + 1, -1) == -1:
					res = 'NO'
					break
				(a[j + 1], a[j]) = (a[j], a[j + 1])
	print(res)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	sortA = sorted(a)
	p = set(map(int, input().split()))
	(chk, last, l) = (True, -1, [])
	for i in range(n):
		l.append(a[i])
		if i + 1 not in p:
			if sorted(l) != sortA[last + 1:i + 1]:
				chk = False
				break
			l = []
			last = i
	print('YES' if chk else 'NO')


t = int(input())

def fun(x, n, a, b, d):
	if d[x] == 1:
		if a[x] > a[x + 1]:
			(a[x], a[x + 1]) = (a[x + 1], a[x])
		if x + 1 < n - 1:
			fun(x + 1, n, a, b, d)
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = sorted(a)
	b = list(map(int, input().split()))
	b.sort(reverse=True)
	d = dict()
	for i in b:
		d[i - 1] = 1
	for i in range(n):
		if i not in d.keys():
			d[i] = 0
	for i in range(m):
		fun(b[i] - 1, n, a, b, d)
	f = 0
	for i in range(n):
		if a[i] != p[i]:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for x in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	aa = sorted(a)
	p = list(map(int, input().split()))
	p = sorted(p)
	for zz in range(101):
		for y in p:
			if a[y - 1] > a[y]:
				(a[y - 1], a[y]) = (a[y], a[y - 1])
			else:
				(a[y - 1], a[y]) = (a[y - 1], a[y])
	if aa != a:
		print('NO')
	else:
		print('YES')


n = int(input())
for _ in range(n):
	(m, n) = input().split(' ')
	arr = list(map(int, input().split(' ')))
	ps = [int(i) - 1 for i in input().split(' ')]
	flag = True
	while flag:
		flag = False
		for p in ps:
			if p == len(arr) - 1:
				continue
			if arr[p] > arr[p + 1]:
				flag = True
				(arr[p + 1], arr[p]) = (arr[p], arr[p + 1])
	asc = all((i == 0 or n >= arr[i - 1] for (i, n) in enumerate(arr)))
	if asc:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(N, k) = tuple(map(int, input().split()))
	arr = list(map(int, input().split()))
	swapables = sorted(list(map(int, input().split())))
	if k + 1 >= N:
		print('YES')
		continue
	collections = []
	i = 0
	while i < k:
		start = swapables[i] - 1
		while i < k - 1 and swapables[i] + 1 == swapables[i + 1]:
			i += 1
		end = swapables[i]
		collections.append((start, end))
		i += 1
	arr_sorted = [sorted(arr[c[0] - 1:c[1] + 1]) for c in collections]
	best_possibility = []
	prev = 0
	for c in collections:
		(s, e) = c
		if prev < s:
			best_possibility += arr[prev:s]
		best_possibility += sorted(arr[s:e + 1])
		prev = e + 1
	best_possibility += arr[prev:]
	if sorted(arr) == best_possibility:
		print('YES')
	else:
		print('NO')


for tc in range(int(input())):
	(n, m) = map(int, input().split())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	c = [0] * n
	b.sort()
	for i in b:
		c[i - 1] = 1
		flag = 1
	for j in range(n):
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				if c[i]:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
				else:
					flag = 0
					break
		if not flag:
			break
	if flag:
		print('YES')
	else:
		print('NO')


def weirdsort(arr):
	x = list(arr)
	y = set()
	x.sort()
	while x != arr:
		for i in range(len(arr) - 1):
			if arr[i] > arr[i + 1]:
				(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
				y.add(i + 1)
	return y
for _ in range(int(input())):
	(n, p) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = set(b)
	ar = set()
	ar = weirdsort(a)
	Ar = list(ar)
	ans = True
	for i in Ar:
		if i not in c:
			ans = False
			break
	if ans:
		print('YES')
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) - 1 for i in input().split()]
	q = 0
	while q != 1000:
		q += 1
		for i in p:
			if a[i] > a[min(n - 1, i + 1)]:
				(a[i], a[min(n - 1, i + 1)]) = (a[min(n - 1, i + 1)], a[i])
	b = a[:]
	b.sort()
	if a == b:
		print('YES')
	else:
		print('NO')


from sys import stdin, exit
from copy import deepcopy
T = int(input())
for _ in range(T):
	(n, m) = map(int, stdin.readline().split())
	a = [int(x) for x in stdin.readline().split()]
	p = [int(x) - 1 for x in stdin.readline().split()]
	intervals = [-1] * n
	c = 0
	p.sort()
	for i in p:
		if intervals[i] == -1:
			if intervals[i + 1] != -1:
				intervals[i] = intervals[i + 1]
			else:
				intervals[i] = c
				intervals[i + 1] = c
				c += 1
		else:
			intervals[i + 1] = intervals[i]
	p = intervals[0]
	create = [p, 0, 0]
	int_range = [create]
	for i in range(1, len(intervals)):
		if intervals[i] != p:
			create = [intervals[i], i, i]
			p = intervals[i]
			int_range.append(create)
		else:
			create[2] += 1
	zz = False
	max_min = []
	for inv in int_range:
		v = inv[0]
		le = inv[1]
		ri = inv[2]
		if v == -1:
			max_min.append(a[le])
			max_min.append(a[ri])
			for i in range(ri - le):
				if a[le + i] > a[le + i + 1]:
					zz = True
		else:
			max_min.append(min(a[le:ri + 1]))
			max_min.append(max(a[le:ri + 1]))
	for bounds in range(len(max_min) - 1):
		if max_min[bounds] > max_min[bounds + 1]:
			zz = True
	if zz:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
t = int(stdin.readline())

def getRoot(i, par):
	while i != par[i]:
		i = par[i]
	return i

def find(a, b, par):
	return getRoot(a, par) == getRoot(b, par)

def doUnion(a, b, par, size):
	if find(a, b, par):
		return False
	r1 = getRoot(a, par)
	r2 = getRoot(b, par)
	s1 = size[r1]
	s2 = size[r2]
	if s1 > s2:
		par[r2] = r1
		size[r1] += s2
	else:
		par[r1] = r2
		size[r2] += s1
	return True
while t > 0:
	(n, p) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	pos = list(map(int, stdin.readline().split()))
	A = [[a[i], i + 1] for i in range(n)]
	par = [i for i in range(101)]
	size = [1 for i in range(101)]
	for i in range(p):
		(x, y) = (pos[i], pos[i] + 1)
		doUnion(x, y, par, size)
	sort = 'YES'
	b = sorted(A)
	for i in range(n):
		(x, y) = (A[i][1], b[i][1])
		if not find(x, y, par):
			sort = 'NO'
			break
	stdout.write('{}\n'.format(sort))
	t -= 1


for test in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	q = list(map(int, input().split()))
	query = [0] * n
	for i in range(len(q)):
		query[q[i] - 1] = True
	while True:
		ok = False
		for i in range(len(arr) - 1):
			if query[i] and arr[i] > arr[i + 1]:
				ok = True
				temp = arr[i + 1]
				arr[i + 1] = arr[i]
				arr[i] = temp
		if ok == False:
			break
	ok = True
	for i in range(len(arr) - 1):
		if arr[i] > arr[i + 1]:
			ok = False
	if ok == False:
		print('NO')
	else:
		print('YES')


from collections import defaultdict
t = int(input())
res = []
for k in range(t):
	(n, m) = map(int, input().split())
	A = [int(x) for x in input().split()]
	P = [int(x) - 1 for x in input().split()]
	edges = defaultdict(list)
	for item in P:
		edges[item].append(item + 1)
		edges[item + 1].append(item)
	visited = [False] * n
	for i in range(n):
		if visited[i]:
			continue
		stack = [i]
		sub = []
		sub_indexes = []
		visited[i] = True
		while len(stack) > 0:
			curr = stack.pop()
			sub.append(A[curr])
			sub_indexes.append(curr)
			for item in edges[curr]:
				if not visited[item]:
					stack.append(item)
					visited[item] = True
		sub_indexes = sorted(sub_indexes)
		sub = sorted(sub)
		curr = 0
		for index in sub_indexes:
			A[index] = sub[curr]
			curr += 1
	if A == sorted(A):
		res.append('YES')
	else:
		res.append('NO')
for item in res:
	print(item)


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = [int(i) - 1 for i in input().split()]
	p.sort()
	mark = [i for i in range(n)]
	for i in p:
		try:
			mark[i + 1] = mark[i]
		except:
			continue
	cur = -1
	f = []
	real = []
	for i in range(n):
		if mark[i] == cur:
			f[-1].append(a[i])
		else:
			cur = mark[i]
			f.append([a[i]])
	for i in f:
		i.sort()
	for i in f:
		real.extend(i)
	if real == sorted(a):
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	pp = list(map(int, input().split()))
	while True:
		starting = list(a)
		for p in pp:
			(a[p - 1], a[p]) = (min(a[p - 1], a[p]), max(a[p - 1], a[p]))
		if a == starting:
			break
	print('YES' if a == sorted(a) else 'NO')


a = int(input())
for f in range(a):
	(n, m) = [int(x) for x in input().split()]
	lista = [int(x) for x in input().split()]
	listp = [int(x) - 1 for x in input().split()]
	listp = sorted(listp)
	while lista != sorted(lista):
		count = 0
		for x in listp:
			if lista[x] > lista[x + 1]:
				count += 1
				(lista[x], lista[x + 1]) = (lista[x + 1], lista[x])
		if count == 0:
			print('NO')
			break
	if lista == sorted(lista):
		print('YES')


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	ai = [*map(int, input().split())]
	p = [*map(int, input().split())]
	for i in range(m):
		for j in p:
			if ai[j - 1] > ai[j]:
				(ai[j - 1], ai[j]) = (ai[j], ai[j - 1])
	if sorted(ai) == ai:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	pos = [0] * (len(a) + 1)
	for i in p:
		pos[i] += 1
	while True:
		(ok, ko) = (True, True)
		for j in range(1, len(a)):
			if a[j] < a[j - 1]:
				ok = False
				if pos[j] == 1:
					(a[j], a[j - 1]) = (a[j - 1], a[j])
				else:
					ko = False
					break
		if ok == True or ko == False:
			break
	if ok == True:
		print('YES')
	if ko == False:
		print('NO')


def f(i, j, s, x):
	(ii, jj) = (i, j)
	indices = [i for (i, xx) in enumerate(s) if xx == x]
	ff = []
	for jj in indices:
		f = True
		if ii == jj:
			f &= True
		elif i < j:
			for p in ps:
				if j == ii:
					break
				if p == ii:
					ii += 1
			if jj != ii:
				f &= False
		elif i > j:
			for p in ps:
				if jj == ii:
					break
				if p == jj:
					jj += 1
			if jj != ii:
				f &= False
		ff.append(f)
	for bool in ff:
		if bool:
			return True
	return False
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	ps = sorted([int(x) - 1 for x in input().split()])
	s = sorted(a)
	d = True
	for i in range(len(a)):
		x = a[i]
		j = s.index(x)
		d &= f(i, j, s, x)
		if not d:
			print('NO')
			break
	if d:
		print('YES')


t = int(input())
for x in range(t):
	ans = True
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = []
	for i in a:
		c.append(i)
	c.sort()
	for i in range(0, n):
		for j in range(0, n - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				x = a[j]
				a[j] = a[j + 1]
				a[j + 1] = x
	if a == c:
		print('YES')
	else:
		print('NO')


I = lambda : map(int, input().split(' '))
t = int(input())
for _ in range(t):
	(n, m) = I()
	arr = list(I())
	permut = list(I())
	while True:
		l = list(arr)
		for p in permut:
			if arr[p - 1] > arr[p]:
				(arr[p - 1], arr[p]) = (arr[p], arr[p - 1])
		if l == arr:
			break
	arr.sort()
	print(['NO', 'YES'][l == arr])


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(n, m) = Read.list_int()
	a = Read.list_int()
	p = Read.list_int()
	for i in range(n - 1):
		for j in range(n - i - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			print('NO')
			return
	print('YES')
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	y.sort()
	chains = []
	while True:
		current_chain = []
		start = y.pop(0)
		current_chain.append(start)
		while True:
			current_chain.append(start + 1)
			if start + 1 not in y:
				break
			else:
				start = y.pop(0)
		chains.append(current_chain)
		if len(y) == 0:
			break
	for chain in chains:
		if chain:
			left = chain[0]
			right = chain[-1]
			x[left - 1:right] = sorted(x[left - 1:right])
	if x == sorted(x):
		print('YES')
	else:
		print('NO')


import collections
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	c = 0
	while True:
		ok = False
		for i in p:
			if a[i - 1] > a[i]:
				ok = True
				(a[i - 1], a[i]) = (a[i], a[i - 1])
		if not ok:
			break
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


for case in range(int(input())):
	(n, p) = [int(x) for x in input().split()]
	series = [int(x) for x in input().split()]
	p_series = [int(x) for x in input().split()]
	p_series.sort()
	new_series = []
	l = p_series[0]
	i = 1
	while i < l:
		new_series.append(series[i - 1])
		i += 1
	l = 0
	l_ind = n + 1
	r_ind = n + 1
	while l < p:
		r = l
		while r + 1 < p and p_series[r + 1] - p_series[r] == 1:
			r += 1
		l_ind = p_series[l] - 1
		for x in series[r_ind + 1:l_ind]:
			new_series.append(x)
		r_ind = p_series[r] + 1 - 1
		temp = series[l_ind:r_ind + 1]
		temp.sort()
		for x in temp:
			new_series.append(x)
		l = r + 1
	for x in series[r_ind + 1:]:
		new_series.append(x)
	series.sort()
	if series == new_series:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	new_list = sorted(a)
	while True:
		flag = 1
		for i in range(n):
			if a[p[i] - 1] > a[p[i]]:
				flag = 0
				(a[p[i] - 1], a[p[i]]) = (a[p[i]], a[p[i] - 1])
		if flag == 1:
			break
	if new_list == a:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ln = list(map(int, input().split()))
	lm = list(map(int, input().split()))
	l = []
	f = 0
	mpp = {}
	for i in lm:
		if i - 1 not in mpp:
			mpp[i - 1] = 1
	for j in range(n):
		for i in range(n - 1):
			if ln[i] > ln[i + 1]:
				l.append(i)
				(ln[i], ln[i + 1]) = (ln[i + 1], ln[i])
	for i in l:
		if i not in mpp:
			f = 1
			break
	if f:
		print('NO')
	else:
		print('YES')


for u in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	d = list(map(int, input().split()))
	x = set()
	f = 0
	for i in range(n - 1):
		for j in range(n - i - 1):
			if l[j] > l[j + 1]:
				if j + 1 in d:
					(l[j], l[j + 1]) = (l[j + 1], l[j])
				else:
					f = 1
					break
	if f == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
import math, bisect, heapq
from collections import Counter, deque, defaultdict
L = lambda : list(map(int, stdin.readline().strip().split()))
I = lambda : int(stdin.readline().strip())
S = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()

def pr(a):
	print(' '.join(list(map(str, a))))

def solve():
	(n, m) = L()
	a = L()
	p = L()
	d = defaultdict(int)
	for i in p:
		d[i - 1] = 1
	b = sorted(a)
	ans = [0] * n
	e = defaultdict(int)
	for i in range(n):
		x = b.index(a[i]) + e[a[i]]
		e[a[i]] += 1
		for j in range(min(i, x), max(i, x)):
			if d[j] == 0:
				print('NO')
				return
	print('YES')
for _ in range(I()):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	s = sorted(a)
	flag = 0
	cnt = 0
	for j in range(1000):
		for i in p:
			if a[i - 1] > a[i]:
				x = a[i - 1]
				a[i - 1] = a[i]
				a[i] = x
			if a == s:
				flag = 1
				break
	if flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	f = 1
	for j in range(m - 1):
		s = 0
		for k in range(m - j - 1):
			if a[k] > a[k + 1]:
				if k + 1 not in p:
					f = 0
					break
				else:
					s = 1
					temp = a[k]
					a[k] = a[k + 1]
					a[k + 1] = temp
		if f == 0 or s == 0:
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	if a == sorted(a):
		print('YES')
	elif len(p) == n - 1:
		print('YES')
	else:
		while True:
			state = False
			for x in p:
				if a[x - 1] > a[x]:
					state = True
					(a[x - 1], a[x]) = (a[x], a[x - 1])
			if not state:
				break
		if a == sorted(a):
			print('YES')
		else:
			print('NO')


def bubbleSort(arr, br):
	n = len(arr)
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1] and j + 1 in br:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
t = int(input())
while t:
	t -= 1
	flag = 0
	(n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	br = list(map(int, input().split()))
	bubbleSort(ar, br)
	for i in range(n - 1):
		if ar[i] > ar[i + 1]:
			flag = 1
			break
	print('YES' if flag == 0 else 'NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	array = list(map(int, input().split()))
	piss = list(map(int, input().split()))
	dick = {}
	for i in piss:
		dick[i - 1, i] = 1
	for i in range(n):
		array[i] = (array[i], i)
	array.sort()
	flag = True
	for i in range(n):
		if not flag:
			break
		for j in range(n):
			k = array[j][1]
			if k == i:
				klag = True
				for t in range(i, j):
					if dick.get((t, t + 1), 0) == 0:
						klag = False
						break
				if not klag:
					flag = False
					break
	if not flag:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	li = set(map(int, input().split()))
	t = 0
	c = 0
	d = a[:]
	d1 = a[:]
	d1.sort()
	while a != sorted(a):
		if c >= m:
			break
		ind = a[c:].index(d1[c]) + c
		while ind >= c + 1:
			if ind not in li:
				t = 1
				break
			else:
				y = a[ind]
				a[ind] = a[ind - 1]
				a[ind - 1] = y
			ind -= 1
		if t == 1:
			break
		else:
			c += 1
	if t == 1:
		print('NO')
	elif a == sorted(d):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set(map(lambda x: int(x) - 1, input().split()))
	c = sorted(a)
	swaps = True
	while swaps:
		swaps = False
		for i in range(n - 1):
			if a[i] > a[i + 1] and i in b:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				swaps = True
	if a == c:
		print('YES')
	else:
		print('NO')


def read_ints():
	return [int(x) for x in input().split()]
t = int(input())
for _ in range(t):
	(n, m) = read_ints()
	a = read_ints()
	p = [x - 1 for x in read_ints()] + [1000]
	p.sort()
	chunk_start = p[0]
	p_chunks = []
	for i in range(1, len(p)):
		if p[i - 1] + 1 < p[i]:
			p_chunks.append([chunk_start, p[i - 1] + 1])
			chunk_start = p[i]
	for (l, r) in p_chunks:
		a[l:r + 1] = sorted(a[l:r + 1])
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


def mi():
	return map(int, input().split())

def li():
	return list(mi())

def ii():
	return int(input())

def si():
	return input()
t = ii()
while t:
	t -= 1
	(n, m) = mi()
	a = li()
	p = li()
	b = []
	for i in range(n - 1):
		for j in range(n - i - 1):
			if a[j] > a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
				b.append(j + 1)
	b = list(set(b))
	f = 0
	for i in b:
		if i not in p:
			f = 1
			break
	if f:
		print('NO')
	else:
		print('YES')


import sys
import math
import collections
import bisect

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

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

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(n, m) = get_ints()
	arr = get_list()
	pos = get_list()
	if sorted(arr) == arr:
		print('YES')
		continue
	dup = arr.copy()
	index = dict()
	for i in range(n):
		if arr[i] in index:
			index[arr[i]].append(i + 1)
		else:
			index[arr[i]] = [i + 1]
	dup.sort()
	poss = 0
	destination = 1
	for i in dup:
		ele = i
		loc = index[ele]
		source = loc[0]
		index[ele].pop(0)
		for j in range(destination, source):
			if j in pos:
				continue
			else:
				poss += 1
				break
		destination += 1
		if poss > 0:
			break
	if poss > 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	b = sorted(a)
	p = sorted(p)
	mark = [0] * n
	for i in p:
		mark[i - 1] = 1
	l = []
	i = 0
	while i < n:
		if mark[i] == 0:
			l.append(a[i])
			i += 1
			continue
		j = i + 1
		while j < n and mark[j - 1] == 1:
			j += 1
		l += sorted(a[i:j])
		i = j
	if l == b:
		print('YES')
	else:
		print('NO')


S_IN = lambda : int(input())
L_IN = lambda : map(int, input().strip().split())

def check_weird_sort(n, m, a, p):
	for j in range(100):
		for i in p:
			if a[i - 1] > a[i]:
				temp = a[i]
				a[i] = a[i - 1]
				a[i - 1] = temp
	is_sorted = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			is_sorted = False
			break
	return 'YES' if is_sorted else 'NO'
for _ in range(S_IN()):
	(n, m) = L_IN()
	a = list(L_IN())
	p = list(L_IN())
	print(check_weird_sort(n, m, a, p))


for _ in range(int(input())):
	input()
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	r = 1
	for i in range(len(a) - 1):
		if r == 0:
			break
		for j in range(len(a) - i - 1):
			if a[j] > a[j + 1]:
				if j + 1 not in p:
					print('NO')
					r = 0
					break
				else:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
	if r:
		print('YES')


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = l1.copy()
	c = 1
	while c <= n:
		for i in range(m):
			if l1[l2[i] - 1] > l1[l2[i]]:
				(l1[l2[i] - 1], l1[l2[i]]) = (l1[l2[i]], l1[l2[i] - 1])
		c = c + 1
	l3.sort()
	if l3 == l1:
		print('YES')
	else:
		print('NO')


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
x = []

def main():
	t = inin()
	for _ in range(t):
		(n, m) = cin()
		a = ain()
		b = ain()
		c = [0] * (n + 1)
		for i in b:
			c[i - 1] = 1
		for j in range(0, n):
			for i in range(1, n):
				if a[i - 1] > a[i] and c[i - 1] == 1:
					(a[i], a[i - 1]) = (a[i - 1], a[i])
		if a == sorted(a):
			print('YES')
		else:
			print('NO')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


t = int(input())

def swap(arr, a, b):
	tmp = arr[a]
	arr[a] = arr[b]
	arr[b] = tmp
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	p = [0 for i in range(n)]
	a = []
	for i in input().split():
		a.append(int(i))
	for i in input().split():
		p[int(i) - 1] = 1
	a2 = sorted(a)
	while True:
		done = True
		for i in range(n):
			if p[i] == 1 and a[i] > a[i + 1]:
				done = False
				swap(a, i, i + 1)
		if done:
			break
	if a == a2:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	p = list(sorted([int(x) for x in input().split()]))
	for _ in range(n + 2):
		for pos in p:
			if a[pos - 1] > a[pos]:
				(a[pos - 1], a[pos]) = (a[pos], a[pos - 1])
	if a == list(sorted(a)):
		print('YES')
	else:
		print('NO')


def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	check = [0] * 101
	for i in p:
		check[i] = 1
	tot = n
	while tot:
		for i in range(n - 1):
			if a[i + 1] < a[i]:
				if check[i + 1] != 0:
					temp = a[i]
					a[i] = a[i + 1]
					a[i + 1] = temp
				else:
					print('NO')
					return
		tot = tot - 1
	print('YES')

def main():
	for _ in range(int(input())):
		solve()
main()


from math import factorial
from collections import Counter
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')
import bisect

def main():
	N = int(input())
	for _ in range(N):
		(n, m) = RL()
		arrn = list(RL())
		arrp = set(RL())
		hp = []
		rec = []
		i = 0
		res = True
		while i < n:
			if i + 1 in arrp:
				while i + 1 in arrp:
					heappush(hp, arrn[i])
					i += 1
				heappush(hp, arrn[i])
			else:
				heappush(hp, arrn[i])
			while hp:
				el = heappop(hp)
				if rec and el < rec[-1]:
					res = False
					break
				rec.append(el)
			i += 1
		if res:
			print('YES')
		else:
			print('NO')
main()


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	v = [0] * n
	k = 1
	a = list(map(int, input().split()))
	x = sorted(a)
	for i in map(int, input().split()):
		v[i - 1] = 1
	for t in range(n - 1):
		for i in range(n - 1):
			if a[i] > a[i + 1] and v[i]:
				(a[i + 1], a[i]) = (a[i], a[i + 1])
			elif a[i] > a[i + 1] and (not v[i]):
				k = 0
				break
		if not k or a == x:
			break
	print('YES' if k else 'NO')


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
for _ in range(I()):
	(n, m) = R()
	a = L()
	p = L()
	for i in range(n):
		for j in range(m):
			if a[p[j] - 1] > a[p[j]]:
				(a[p[j] - 1], a[p[j]]) = (a[p[j]], a[p[j] - 1])
	cnt = sum([a[i] > a[i + 1] for i in range(n - 1)])
	print(['NO', 'YES'][cnt == 0])


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = [int(i) - 1 for i in input().split()]
	p.sort()
	mark = [i for i in range(n)]
	for i in p:
		try:
			mark[i + 1] = mark[i]
		except:
			continue
	cur = -1
	f = []
	real = []
	for i in range(n):
		if mark[i] == cur:
			f[-1].append(a[i])
		else:
			cur = mark[i]
			f.append([a[i]])
	maxx = [max(f[0])]
	ans = 'YES'
	for i in f[1:]:
		maxx.append(max(max(i), maxx[-1]))
	for i in range(1, len(f)):
		if maxx[i - 1] > min(f[i]):
			ans = 'NO'
			break
	print(ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	lst = list(map(int, input().split()))
	ps = list(map(lambda x: int(x) - 1, input().split()))
	srt = sorted(lst)
	ps.sort()
	if n - 1 == m or lst == srt:
		print('YES')
	else:
		st = 0
		end = 0
		while end < m:
			end += 1
			while end < m and ps[end] == ps[end - 1] + 1:
				end += 1
			lst = lst[:ps[st]] + sorted(lst[ps[st]:ps[end - 1] + 2]) + lst[ps[end - 1] + 2:]
			st = end
		if srt == lst:
			print('YES')
		else:
			print('NO')


t = int(input())
while t != 0:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	flag = 0
	for i in range(n - 1):
		mIndx = a[i:].index(min(a[i:])) + i
		check = list(range(i + 1, mIndx + 1))
		for el in check:
			if el not in p:
				flag = 1
				break
		if flag == 1:
			break
		else:
			temp = a[mIndx]
			for k in range(mIndx, i - 1, -1):
				a[k] = a[k - 1]
			a[i] = temp
	if flag == 1:
		print('NO')
	else:
		print('YES')
	t = t - 1


def getIn():
	return input().strip()

def findConflist(arr, lo, hi):
	minin = min(arr[lo:hi + 1])
	maxin = min(arr[lo:hi + 1])
	sub = arr[:lo]
	if len(sub) > 0:
		b = max(sub)
		if b > minin:
			return False
		if not all((sub[i] <= sub[i + 1] for i in range(len(sub) - 1))):
			return False
	sub = arr[hi + 1:]
	if len(sub) > 0:
		b = min(sub)
		if b < maxin:
			return False
	arr[:hi + 1] = sorted(arr[:hi + 1])
	return True
t = int(getIn())
for _ in range(t):
	(n, m) = list(map(int, getIn().split(' ')))
	arr = list(map(int, getIn().split(' ')))
	p = list(map(int, getIn().split(' ')))
	p = list(map(lambda x: x - 1, p))
	p.sort()
	lo = p[0]
	hi = p[0]
	done = True
	for n in p[1:]:
		if n == hi + 1:
			hi = hi + 1
			continue
		else:
			if hi == len(arr) - 2:
				hi += 1
			done = findConflist(arr, lo, hi + 1)
			lo = n
			hi = n
			if not done:
				break
	if done:
		if hi == len(arr) - 2:
			hi += 1
		done = findConflist(arr, lo, hi + 1)
	if done:
		done = all((arr[i] <= arr[i + 1] for i in range(len(arr) - 1)))
	if done:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in range(m):
		b[i] -= 1
	flag = 0
	p = sorted(a)
	b.sort()
	prev = 0
	if a[:b[0]] != p[:b[0]]:
		print('NO')
		continue
	if a[b[i] + 2:] != p[b[i] + 2:]:
		print('NO')
		continue
	for i in range(m - 1):
		if b[i + 1] - b[i] > 1:
			if sorted(a[prev:b[i] + 2]) != p[prev:b[i] + 2]:
				flag = 1
				break
			else:
				if a[b[i] + 2:b[i + 1]] != p[b[i] + 2:b[i + 1]]:
					flag = 1
					break
				prev = b[i + 1]
	print('YES' if flag == 0 else 'NO')


t = int(input())
for k in range(t):
	(n, m) = tuple((int(i) for i in input().split(' ')))
	a = [int(i) for i in input().split(' ')]
	p = [int(i) for i in input().split(' ')]
	for i in range(n):
		for j in range(n - i - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	sorted = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			sorted = False
			break
	if sorted:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict

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

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007
for t in range(I()):
	(n, m) = In()
	arr = L()
	lis = L()
	lis.sort()
	for i in range(n):
		for j in lis:
			(arr[j - 1], arr[j]) = sorted(arr[j - 1:j + 1])
	if arr == sorted(arr):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = set(map(int, input().split()))
	for i in range(len(l)):
		for j in range(len(l) - 1):
			if l[j] > l[j + 1] and j + 1 in p:
				(l[j], l[j + 1]) = (l[j + 1], l[j])
	ans = True
	for i in range(len(l) - 1):
		if l[i] > l[i + 1]:
			ans = False
			break
	print('YES' if ans else 'NO')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	arrsort = []
	prefix = [0] * (n + 1)
	for i in range(n):
		arrsort.append((arr[i], i))
	for poss in pos:
		prefix[poss] = 1
	for i in range(1, n + 1):
		prefix[i] += prefix[i - 1]
	arrsort.sort()
	ans = True
	for i in range(n):
		(val, ind) = arrsort[i]
		if ind > i:
			if prefix[ind] - prefix[i] < ind - i:
				ans = False
	if ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	a = []
	b = []
	l = 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	b = list(map(int, input().split()))[:m]
	for j in range(0, n - 1):
		for k in range(0, n - 1):
			if a[k + 1] < a[k]:
				(a[k + 1], a[k]) = (a[k], a[k + 1])
				if k + 1 not in b:
					l = 0
					break
		if l == 0:
			break
	if l == 1:
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for query in range(t):
		(N, M) = (int(i) for i in input().split())
		par = [i for i in range(105)]
		rank = [0 for i in range(105)]

		def find_root(x):
			if par[x] == x:
				return x
			else:
				par[x] = find_root(par[x])
				return par[x]

		def is_same_group(x, y):
			return find_root(x) == find_root(y)

		def unite(x, y):
			x = find_root(x)
			y = find_root(y)
			if x == y:
				return
			if rank[x] < rank[y]:
				par[x] = y
			else:
				par[y] = x
				if rank[x] == rank[y]:
					rank[x] += 1
		A = [int(i) for i in input().split()]
		B = sorted([(a, i) for (i, a) in enumerate(A)])
		P = [int(i) for i in input().split()]
		for p in P:
			unite(p - 1, p)
		for i in range(N):
			if not is_same_group(i, B[i][1]):
				print('NO')
				break
		else:
			print('YES')
main()


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	flag = True
	aa = sorted(a)
	for i in range(len(a) - 1):
		for j in range(len(a) - i - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if a == aa:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	s = sorted(a)
	for j in range(m):
		if j == 0:
			b = [[p[0], p[0] + 1]]
			continue
		if p[j - 1] + 1 == p[j]:
			b[-1][1] += 1
		else:
			b.append([p[j], p[j] + 1])
	for x in b:
		(l, r) = x
		l -= 1
		r -= 1
		c = a[l:r + 1]
		d = sorted(c)
		for i in range(l, r + 1):
			a[i] = d[i - l]
	if s == a:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	for j in range(n):
		b.append([a[j], j, 0])
	b.sort()
	p = list(map(int, input().split()))
	p.sort()
	c = [[0] * n for j in range(n)]
	for j in p:
		c[j - 1][j] = 1
		c[j][j - 1] = 1
	possible = True
	for j in range(n):
		if b[j][2] == 0:
			if b[j][1] != j:
				if b[j][1] < j:
					s = 1
					q = 1
				else:
					q = 0
					s = -1
				for l in range(b[j][1] + q, j, s):
					if c[l - 1][l] != 1:
						possible = False
						break
		if not possible:
			break
	if possible:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a_n, p_n) = map(int, input().split())
	a = list(map(int, input().split()))
	p_before = list(map(int, input().split()))
	p = [0] * a_n
	for i in range(len(p_before)):
		p[p_before[i] - 1] += 1
	while True:
		ok = False
		for i in range(len(a) - 1):
			if p[i] and a[i] > a[i + 1]:
				ok = True
				(a[i], a[i + 1]) = (a[i + 1], a[i])
		if not ok:
			break
	okay = False
	for i in range(len(a) - 1):
		if a[i] <= a[i + 1]:
			okay = True
		else:
			okay = False
			break
	if okay:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().rstrip().split(' '))
	a = list(map(int, input().rstrip().split(' ')))
	p = list(map(int, input().rstrip().split(' ')))
	check = a.copy()
	check.sort()
	p.sort()
	p = [i - 1 for i in p]
	l = [0] * n
	for i in p:
		l[i] = 1
	s = []
	e = []
	if l[0] == 1:
		s.append(0)
	for i in range(1, len(l)):
		if l[i] == 1 and l[i - 1] == 0:
			s.append(i)
		elif l[i] == 0 and l[i - 1] == 1:
			e.append(i)
	if l[-1] == 1:
		e.append(len(l) - 1)
	for j in range(len(s)):
		a[s[j]:e[j] + 1] = sorted(a[s[j]:e[j] + 1])
	if a == check:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	while True:
		r = 0
		for i in range(m):
			if a[p[i] - 1] > a[p[i]]:
				(a[p[i] - 1], a[p[i]]) = (a[p[i]], a[p[i] - 1])
				r = r + 1
		if r == 0:
			break
	d = sorted(a)
	if a == d:
		print('YES')
	else:
		print('NO')


import sys
import math
import heapq
import collections
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')

def printspace(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer(' ')

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

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

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, m) = inputnums()
	a = inputlist()
	p = inputlist()
	for i in range(m):
		p[i] -= 1
	p.sort()
	start = p[0]
	end = p[0]
	for i in range(m):
		if i < m - 1 and p[i + 1] == p[i] + 1:
			end += 1
			if i == m - 2:
				a[start:end + 2] = sorted(a[start:end + 2])
		else:
			a[start:end + 2] = sorted(a[start:end + 2])
			if i == m - 1:
				break
			start = p[i + 1]
			end = p[i + 1]
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


from math import *

def sorted(x):
	for i in range(len(x) - 1):
		if x[i] > x[i + 1]:
			return False
	return True

def sort(a, p):
	for k in range(len(a) * 10):
		for i in range(len(a) - 1):
			if a[i] > a[i + 1] and i in p:
				t = a[i]
				a[i] = a[i + 1]
				a[i + 1] = t
	return sorted(a)
t = int(input())
for zz in range(t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) - 1 for i in input().split()]
	if sort(a, p):
		print('YES')
	else:
		print('NO')


for nt in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p = set(p)
	if m >= n - 1:
		print('YES')
		continue
	flag = 0
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1]:
				if j + 1 not in p:
					flag = 1
					break
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
	if flag == 1:
		print('NO')
	else:
		print('YES')


from math import *

def binarySearch(arr, x, i):
	l = i
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans

def ceil(a, b):
	if a % b == 0:
		return int(a / b)
	else:
		return a // b + 1
for __ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort()
	t = []
	t2 = []
	for i in range(n):
		t.append(a[i])
		t2.append([a[i], i])
	t.sort()
	t2.sort()
	d = {}
	for i in range(m):
		d[b[i] - 1] = 1
	if t == a or (m == n and m == n - 1):
		print('YES')
	else:
		ans = 'YES'
		for i in range(n):
			if t2[i][1] > i:
				for j in range(i, t2[i][1]):
					if d.get(j) == None:
						ans = 'NO'
						break
			if ans == 'NO':
				break
		print(ans)


t = int(input())
for q in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	x = sorted(a)
	b = set(map(int, input().split()))
	for i in range(n):
		swap = 0
		for j in range(n - 1 - i):
			if a[j] > a[j + 1] and j + 1 in b:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
				swap += 1
		if swap == 0:
			break
	if x == a:
		print('YES')
	else:
		print('NO')


for tests in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	flag = True
	while flag:
		flag = False
		for i in range(m):
			if a[p[i] - 1] > a[p[i]]:
				(a[p[i] - 1], a[p[i]]) = (a[p[i]], a[p[i] - 1])
				flag = True
	flag = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


import sys
T = int(input())
for i in range(T):
	k = list(map(int, sys.stdin.readline().split()))
	board = list(map(int, sys.stdin.readline().split()))
	board2 = list(map(int, sys.stdin.readline().split()))
	while True:
		check = True
		for j in board2:
			if board[j - 1] > board[j] and j < k[0]:
				tmp = board[j]
				board[j] = board[j - 1]
				board[j - 1] = tmp
				check = False
		if check:
			break
	check = True
	for value in range(0, len(board) - 1):
		if not board[value] <= board[value + 1]:
			check = False
	if check:
		print('YES')
	else:
		print('NO')


from bisect import bisect_left
output = []
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	pos_d = {}
	for i in pos:
		pos_d[i - 1] = True
	i = 0
	while i < n:
		if i not in pos_d:
			i += 1
			continue
		j = i
		while j < n and j in pos_d:
			j += 1
		arr[i:j + 1] = sorted(arr[i:j + 1])
		i = j
		i += 1
		if i >= n - 1:
			break
	ok = True
	for i in range(0, n - 1):
		ok &= arr[i] <= arr[i + 1]
	print('YES' if ok else 'NO')


def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	f = lambda x: int(x) - 1
	p = set(map(f, input().split()))
	b = sorted(a)
	for i in range(n):
		if a[i] != b[i]:
			idx = b.index(a[i])
			b[idx] = None
			for j in range(i, idx):
				if j not in p:
					return False
	return True
t = int(input())
for _ in range(t):
	if solve():
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		p = list(map(int, input().split()))
		allowed = [False] * n
		for pi in p:
			allowed[pi - 1] = True
		ans = True
		for i in range(1, n):
			for j in range(i, 0, -1):
				if a[j] >= a[j - 1]:
					break
				if not allowed[j - 1]:
					ans = False
					break
				(a[j], a[j - 1]) = (a[j - 1], a[j])
			if not ans:
				break
		print('YES' if ans else 'NO')
main()


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(m):
		for j in p:
			if arr[j - 1] > arr[j]:
				(arr[j - 1], arr[j]) = (arr[j], arr[j - 1])
	if sorted(arr) == arr:
		print('YES')
	else:
		print('NO')


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
t = int(readline())
for _ in range(t):
	(n, m) = map(int, readline().split())
	lst1 = list(map(int, readline().split()))
	lst2 = list(map(int, readline().split()))
	ans = lst1[:]
	ans.sort()
	while True:
		flag = 1
		for i in lst2:
			if lst1[i - 1] > lst1[i]:
				(lst1[i - 1], lst1[i]) = (lst1[i], lst1[i - 1])
				flag = 0
		if lst1 == ans:
			print('YES')
			break
		if flag:
			print('NO')
			break


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lis = list(map(int, input().split()))
	tem = lis[:]
	aa = [0] * 102
	pos = list(map(int, input().split()))
	for i in pos:
		aa[i] = 1
	i = 0
	while i < 101:
		if aa[i] == 1:
			j = i + 1
			while aa[j] == 1:
				j += 1
			tem[i - 1:j] = sorted(tem[i - 1:j])
			i = j
		else:
			i += 1
	lis.sort()
	if lis == tem:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	swap = 1
	while swap != 0:
		swap = 0
		for i in range(m):
			if a[p[i] - 1] > a[p[i]]:
				t = a[p[i]]
				a[p[i]] = a[p[i] - 1]
				a[p[i] - 1] = t
				swap = 1
	flag = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


input = __import__('sys').stdin.readline
print = __import__('sys').stdout.write
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = sorted(list(map(int, input().split())))
	rr = []
	start = p[0]
	current = p[0]
	for i in range(1, m):
		if p[i] - current == 1:
			current = p[i]
			continue
		else:
			rr.append((start - 1, current))
			start = p[i]
			current = p[i]
	else:
		rr.append((start - 1, current))
	for (i, j) in rr:
		a[i:j + 1] = sorted(a[i:j + 1])
	for i in range(1, len(a)):
		if a[i] < a[i - 1]:
			print('NO\n')
			break
	else:
		print('YES\n')


t = int(input())
for q in range(0, t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	b = sorted(a)
	p.sort()
	for i in range(0, n):
		for j in range(0, m):
			if a[p[j] - 1] > a[p[j]]:
				(a[p[j] - 1], a[p[j]]) = (a[p[j]], a[p[j] - 1])
	if a == b:
		print('YES')
	else:
		print('NO')


import sys
from collections import defaultdict
from itertools import permutations, combinations
import string
from heapq import heapify, heappush, heappop

def solve():

	def can(curr, idx, pairs):
		for i in range(curr, idx):
			if pairs[i] == 0:
				return False
		return True
	alphabets = string.ascii_lowercase
	digits = string.digits
	get_arr = lambda type_=int: list(map(type_, sys.stdin.readline().rstrip('\n').split()))
	inp = lambda type_=int: type_(sys.stdin.readline().rstrip('\n'))
	pair = lambda type_=int: map(type_, sys.stdin.readline().rstrip('\n').split(' '))
	t = inp()
	for _ in range(t):
		f = True
		(m, n) = pair()
		arr = get_arr()
		pairs = get_arr()
		for i in range(len(pairs)):
			pairs[i] -= 1
		d = defaultdict(int)
		for p in pairs:
			d[p] += 1
		sorted_arr = sorted(arr)
		for (i, ele) in enumerate(arr):
			org_idx = sorted_arr.index(ele)
			if not can(i, org_idx, d):
				f = False
				break
			sorted_arr[org_idx] = -1
		if f:
			print('YES')
		else:
			print('NO')
solve()


def check_array(array, array1):
	dict = {}
	for j in array:
		if j in dict:
			dict[j] += 1
		else:
			dict[j] = 1
	for j in array1:
		if j not in dict:
			return False
		elif dict[j] == 0:
			return False
		else:
			dict[j] -= 1
	return True
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	n_list = list(map(int, input().split()))
	m_list = list(map(int, input().split()))
	req_list = sorted(n_list)
	vis = [0] * n
	for i in m_list:
		vis[i - 1] = 1
	f = 1
	last = 0
	for i in range(n):
		if vis[i] == 1:
			last_vis = i + 1
	k = 0
	for i in range(n):
		if vis[i] == 0 and last_vis < i:
			k = 1
			break
		if vis[i] == 0:
			if not check_array(n_list[last:i + 1], req_list[last:i + 1]):
				f = 0
				break
			else:
				last = i + 1
	if k == 1:
		for l in range(i + 1, n):
			if req_list[l] != n_list[l]:
				f = 0
				break
	if f == 0:
		print('NO')
	else:
		print('YES')


t = int(input())

def bubbleSort(arr):
	n = len(arr)
	global ava
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1]:
				if ava[j] == 1:
					(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
for i in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = a[:]
	p = list(map(int, input().split()))
	ava = [0] * len(a)
	for j in p:
		ava[j - 1] = 1
	b.sort()
	bubbleSort(a)
	if a == b:
		print('YES')
	else:
		print('NO')


def can_perform_weird_sort(numbers_length, numbers_data, switch_length, switch_data):
	if numbers_length == 1:
		return 'YES'
	for i in range(numbers_length - 1, -1, -1):
		for j in range(i, numbers_length):
			if j < numbers_length - 1:
				if numbers_data[j] > numbers_data[j + 1] and j + 1 in switch_data:
					(numbers_data[j], numbers_data[j + 1]) = (numbers_data[j + 1], numbers_data[j])
	sorting_performed = 'YES'
	for k in range(numbers_length - 1):
		if numbers_data[k] > numbers_data[k + 1]:
			sorting_performed = 'NO'
	return sorting_performed
number_of_tests = int(input())
for _ in range(number_of_tests):
	(n, m) = tuple(map(int, input().split()))
	data = list(map(int, input().split()))
	p = list(map(int, input().split()))
	print(can_perform_weird_sort(n, data, m, sorted(p)))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	aa = a[:]
	aa.sort()
	flag = 1
	for j in range(n):
		if j + 1 not in p:
			test1 = a[:j + 1]
			test2 = aa[:j + 1]
			test1.sort()
			if test1 != test2:
				flag = 0
				break
	if flag == 0:
		print('NO')
	else:
		print('YES')


import random, math
from copy import deepcopy as dc
from bisect import bisect_left, bisect_right

def solution(li, li1):
	li1 = sorted(li1)
	for i in range(len(li)):
		for j in range(len(li1)):
			(li[li1[j] - 1], li[li1[j]]) = (min(li[li1[j] - 1], li[li1[j]]), max(li[li1[j] - 1], li[li1[j]]))
	if li == sorted(li):
		return True
	return False

def input_test():
	for _ in range(int(input())):
		(n, m) = map(int, input().strip().split(' '))
		li = list(map(int, input().strip().split(' ')))
		li1 = set(list(map(int, input().strip().split(' '))))
		out = solution(li, li1)
		print('YES' if out else 'NO')

def test():
	pass
input_test()


t = int(input())
for qwe in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = set(map(int, input().split()))
	for i in range(n):
		a[i] = (a[i], i)

	def key1(a):
		return a[0]
	a.sort(key=key1)
	flag = True
	for i in range(n):
		for j in range(i, a[i][1]):
			if not j + 1 in p:
				flag = False
				break
		if not flag:
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	ans = sorted(a)
	flg = 0
	while True:
		for i in range(len(a) - 1):
			if a[i] > a[i + 1] and i + 1 in p:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
			elif a[i] > a[i + 1] and i + 1 not in p:
				flg = 1
			if a == ans:
				flg = 1
		if flg:
			break
	if a == ans:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	dp = [i for i in range(n)]
	p = [int(x) for x in input().split()]
	p.sort()
	d = {}
	mini = {}
	maxi = {}
	for v in p:
		dp[v] = dp[v - 1]
	for i in dp:
		d[i] = True
	for i in d:
		mini[i] = float('inf')
		maxi[i] = float('-inf')
	dp2 = [(-1, float('-inf'), float('-inf'))]
	for i in range(n):
		mini[dp[i]] = min(mini[dp[i]], a[i])
		maxi[dp[i]] = max(maxi[dp[i]], a[i])
	flag = False
	for k in d:
		dp2.append((k, mini[k], maxi[k]))
	dp2.append((n, float('inf'), float('inf')))
	dp2.sort(key=lambda k: k[0])
	for k in range(1, len(dp2) - 1):
		if dp2[k - 1][2] > dp2[k][1] or dp2[k][2] > dp2[k + 1][1]:
			print('NO')
			flag = True
			break
	if flag == False:
		print('YES')
	t -= 1


def solve(a, b):
	b.sort()
	start = 0
	inc = True
	for i in range(1, len(b)):
		if b[i] - b[start] != i - start:
			a[b[start]:b[i - 1] + 2] = sorted(a[b[start]:b[i - 1] + 2])
			start = i
			inc = False
	a[b[start]:b[-1] + 2] = sorted(a[b[start]:b[-1] + 2])
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			return 'NO'
	return 'YES'
line = int(input())
for _ in range(line):
	input()
	a = [int(i) for i in input().split(' ')]
	b = [int(i) - 1 for i in input().split(' ')]
	print(solve(a, b))


from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 8)
input = stdin.readline

def dfs(p):
	v[p] = True
	x = []
	for i in adj[p]:
		x += dfs(i)
	return x + [b[p - 1]]

def answer():
	for i in p:
		if not v[i]:
			x1 = dfs(i)[::-1]
			x2 = []
			for j in range(i - 1, i - 1 + len(x1)):
				x2.append(a[j])
			if x1 != sorted(x2):
				return 'NO'
	for i in range(n):
		if not v[i + 1]:
			if a[i] != b[i]:
				return 'NO'
	return 'YES'
for T in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = sorted(list(map(int, input().split())))
	adj = [[] for i in range(n + 1)]
	for i in p:
		adj[i].append(i + 1)
	v = [False] * (n + 1)
	b = sorted(a)
	print(answer())


from sys import stdin, stdout
import traceback
from collections import Counter, defaultdict
read = stdin.readline
write = stdout.write
writeln = lambda x: write(str(x) + '\n')

def reads(typ=int):
	return list(map(typ, read().split()))

class Sol:

	@classmethod
	def input(cls):
		s = cls()
		return s

	def solve(self):
		(n, m) = reads()
		aa = reads()
		pp = reads()
		count_a = Counter()
		aa = [a * 1000 + count_a[a] for a in aa]
		new_aa = []
		for a in aa:
			count_a[a] += 1
			new_aa.append(a * 1000 + count_a[a])
		sorted_aa = sorted(new_aa)
		aa = new_aa
		swapable = set()
		for p in pp:
			swapable.add(p - 1)
		iis = {}
		for (i, a) in enumerate(sorted_aa):
			iis[a] = i
		for (i, a) in enumerate(aa):
			j = iis[a]
			if j >= i:
				continue
			for x in range(j, i):
				if x not in swapable:
					return False
		return True
try:
	for _ in range(int(read())):
		res = Sol.input().solve()
		writeln('YES' if res else 'NO')
except Exception as e:
	print('Got exception:', repr(e))
	print(traceback.format_exc())


t = int(input())
for j in range(t):
	(n, m) = map(int, input().split())
	lis_1 = [int(x) for x in input().split()]
	s = set([int(x) for x in input().split()])
	p = 0
	lis = []
	for i in range(1, n + 1):
		if i not in s:
			if p != 0:
				lis += [min(lis_1[i - p - 1:i]), max(lis_1[i - p - 1:i])]
			else:
				lis.append(lis_1[i - 1])
			p = 0
		else:
			p += 1
	for i in range(len(lis) - 1):
		if lis[i] > lis[i + 1]:
			print('NO')
			break
	else:
		print('YES')


def valid(li, positions):
	while True:
		count = 0
		for i in range(len(li) - 1):
			if li[i] > li[i + 1]:
				count += 1
				if i + 1 in positions:
					(li[i], li[i + 1]) = (li[i + 1], li[i])
				else:
					return False
		if count == 0:
			return True
t = int(input())
while t:
	(n, m) = [int(x) for x in input().split()]
	li = [int(x) for x in input().split()]
	positions = [int(x) for x in input().split()]
	print('YES') if valid(li, positions) else print('NO')
	t -= 1


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(x, y):
	return f(x) // (f(y) * f(x - y))
t = int(input())

def dfs(n):
	boo[n] = True
	seti.add(n)
	for i in hash[n]:
		if not boo[i]:
			dfs(i)
for _ in range(t):
	(n, m) = map(int, input().split())
	l2 = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	hash = defaultdict(list)
	for i in l1:
		z1 = l2[i - 1]
		z2 = l2[i]
		hash[i - 1].append(i)
		hash[i].append(i - 1)
	boo = defaultdict(bool)
	la = []
	for i in range(n):
		if not boo[i]:
			seti = set()
			seti.add(i)
			dfs(i)
			la.append(seti)
	for i in la:
		yo = []
		bo = []
		for j in i:
			for k in range(n):
				if k == j:
					yo.append([l2[k], k])
					bo.append(k)
					break
		yo.sort()
		bo.sort()
		k = 0
		for a in bo:
			l2[a] = yo[k][0]
			k += 1
	if l2 == sorted(l2):
		print('YES')
	else:
		print('NO')


for _ in ' ' * int(input()):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p = set(p)
	s = sorted([[a[i], i] for i in range(n)])
	x = 0
	for i in range(n):
		(f, j) = s[i]
		for u in range(i, j):
			if u + 1 not in p:
				x = 1
	for i in range(n):
		(f, j) = s[i]
		for u in range(j, i):
			if u + 1 not in p:
				x = 1
	print(['YES', 'NO'][x == 1])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	lm = list(map(int, input().split()))
	pos = [0] * n
	for i in lm:
		pos[i - 1] = 1
	while 1:
		ok = 0
		for i in range(0, n - 1):
			if l[i] > l[i + 1] and pos[i] == 1:
				temp = l[i]
				l[i] = l[i + 1]
				l[i + 1] = temp
				ok = 1
		if ok == 0:
			break
	ans = 0
	for i in range(0, n - 1):
		if l[i] > l[i + 1]:
			ans = 1
			break
	if ans == 1:
		print('NO')
	else:
		print('YES')


class FindUnionSet:

	def __init__(self, n):
		self.f = [i for i in range(n)]

	def find(self, x):
		if self.f[x] != x:
			self.f[x] = self.find(self.f[x])
		return self.f[x]

	def union(self, x, y):
		if x > y:
			(x, y) = (y, x)
		fx = self.find(x)
		fy = self.find(y)
		self.f[fx] = fy
kase = int(input())
for k in range(kase):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	t = sorted(a)
	s = FindUnionSet(n)
	for i in p:
		s.union(i - 1, i)
	(left, i) = (0, 0)
	while i < n:
		if s.find(i) == i:
			if sorted(a[left:i + 1]) != t[left:i + 1]:
				print('NO')
				break
			left = i + 1
		i += 1
	else:
		print('YES')


from collections import defaultdict
t = int(input().strip())

class Graph:

	def __init__(self, V):
		self.V = V + 1
		self.edges = defaultdict(list)

	def addEdge(self, u, v):
		if v not in self.edges[u]:
			self.edges[u].append(v)

	def DFS(self, source, destination):
		visited = [False] * self.V
		stack = []
		stack.append(source)
		while len(stack):
			s = stack.pop()
			if s == destination:
				return True
			if not visited[s]:
				visited[s] = True
			for node in self.edges[s]:
				if not visited[node]:
					stack.append(node)
		return False
for _ in range(t):
	(n, m) = list(map(int, input().strip().split()))
	arr_n = list(map(int, input().strip().split()))
	arr = list(zip(arr_n, range(1, n + 1)))
	arr.sort()
	arr_m = list(map(int, input().strip().split()))
	arr_m.sort()
	g = Graph(n)
	for i in range(m):
		j = arr_m[i]
		g.addEdge(j, j + 1)
		g.addEdge(j + 1, j)
	for i in range(n):
		if not g.DFS(i + 1, arr[i][1]):
			print('NO')
			break
	else:
		print('YES')


num = int(input())
for i in range(num):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = 1
	while c != 0:
		c = 0
		for j in range(len(p)):
			if a[p[j] - 1] > a[p[j]]:
				c += 1
				(a[p[j] - 1], a[p[j]]) = (a[p[j]], a[p[j] - 1])
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	p = [int(y) - 1 for y in input().split()]
	b = a
	for __ in range(n):
		for i in p:
			if b[i] > b[i + 1]:
				t = b[i]
				b[i] = b[i + 1]
				b[i + 1] = t
	if b == sorted(a):
		print('YES')
	else:
		print('NO')


t = int(input())
arr = []
stri = []
for i in range(t):
	_ = input()
	stri.append(list(map(int, input().split())))
	arr.append(list(map(int, input().split())))

def solve(p, a):
	for i in range(len(a) - 1):
		for j in range(len(a) - i - 1):
			if a[j + 1] < a[j]:
				if j + 1 in p:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
				else:
					return 'NO'
	return 'YES'
for i in range(len(arr)):
	print(solve(arr[i], stri[i]))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l1 = [int(x) for x in input().split()]
	l2 = []
	t = []
	for x in l1:
		l2.append(x)
	l2.sort()
	m = [int(x) for x in input().split()]
	m.sort()
	mlen = len(m)
	q = [m[0], m[0] + 1]
	t = [m[0], m[0] + 1]
	flag = 0
	for x in m[1:]:
		if q[-1] == x:
			q.append(x + 1)
			t.append(x + 1)
		else:
			qlen = len(q)
			l = []
			for y in range(q[0] - 1, q[-1]):
				l.append(l1[y])
			l.sort()
			if l != l2[q[0] - 1:q[-1]]:
				flag = 1
			q = [x, x + 1]
			t.append(x)
			t.append(x + 1)
			if flag == 1:
				break
	if len(q) > 0:
		qlen = len(q)
		l = []
		for y in range(q[0] - 1, q[-1]):
			l.append(l1[y])
		l.sort()
		if l != l2[q[0] - 1:q[-1]]:
			flag = 1
	for x in range(1, a + 1):
		if x in t:
			continue
		if l1[x - 1] != l2[x - 1]:
			flag = 1
			break
	print('YES' if flag == 0 else 'NO')


t = int(input())
for i in range(t):
	n_m = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	data = [[0 for j in range(2)] for k in range(n_m[0])]
	for j in range(n_m[0]):
		data[j][0] = arr[j]
		data[j][1] = j
	p = list(map(int, input().split()))
	data.sort()
	flag = 0
	for j in range(n_m[0]):
		if flag == 0:
			diff = j - data[j][1]
			if diff > 0:
				for k in range(data[j][1], j):
					if k + 1 not in p:
						flag = 1
						break
			elif diff < 0:
				for k in range(j, data[j][1]):
					if k + 1 not in p:
						flag = 1
						break
		else:
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(M, N) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	target = sorted(arr)
	while True:
		for i in range(M - 1):
			if arr[i] > arr[i + 1] and i + 1 in p:
				(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
				break
		else:
			break
	print('YES' if arr == target else 'NO')


t = int(input())
for i in range(t):
	val = list(map(int, input().split()))
	n = val[0]
	m = val[1]
	arr = list(map(int, input().split()))
	chg = list(map(int, input().split()))
	start = chg[0]
	end = chg[0]
	chg.sort()
	for elt in chg:
		if elt == start:
			continue
		elif elt == end + 1:
			end = elt
			arr[start - 1:end + 1] = sorted(arr[start - 1:end + 1])
		else:
			arr[start - 1:start + 1] = sorted(arr[start - 1:start + 1])
			start = elt
			end = elt
	arr[start - 1:start + 1] = sorted(arr[start - 1:start + 1])
	if sorted(arr) == arr:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr3 = []
	for k in arr1:
		arr3.append(k)
	arr3.sort()
	flag = 0
	for f in range(100):
		for x in arr2:
			if arr1[x - 1] > arr1[x]:
				aux = arr1[x - 1]
				arr1[x - 1] = arr1[x]
				arr1[x] = aux
		if arr1 == arr3:
			flag = 1
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	i = 0
	while i < m:
		j = i + 1
		while j < m and p[j] == p[j - 1] + 1:
			j += 1
		a = l[p[i] - 1:p[j - 1] + 1]
		a.sort()
		tt = 0
		for k in range(p[i] - 1, p[j - 1] + 1):
			l[k] = a[tt]
			tt += 1
		i = j
	if sorted(l) == l:
		print('YES')
	else:
		print('NO')


t = int(input())
for T in range(t):
	(n, m) = map(int, input().strip().split())
	v = list(map(int, input().strip().split()))
	u = [0] * n
	for i in list(map(int, input().strip().split())):
		u[i - 1] = 1
	for i in range(n):
		j = i
		while j > 0 and u[j - 1] and (v[j] < v[j - 1]):
			(v[j], v[j - 1]) = (v[j - 1], v[j])
			j -= 1
	if v == sorted(v):
		print('YES')
	else:
		print('NO')


n = int(input())
for j in range(n):
	l = input()
	a = input()
	a = [int(i) for i in a.split()]
	p = input()
	p = [int(i) for i in p.split()]
	p.sort()
	count = 1
	while count != 0:
		count = 0
		for i in p:
			if a[i - 1] > a[i]:
				count += 1
				(a[i - 1], a[i]) = (a[i], a[i - 1])
	sortFlag = True
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			sortFlag = False
			print('NO')
			break
	if sortFlag:
		print('YES')


def bubbleSort(arr):
	n = len(arr)
	a = []
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1]:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
				a.append(j + 1)
	return list(set(a))
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = set(p)
	b = bubbleSort(a)
	d = 0
	for i in b:
		if i in c:
			d = d + 1
	if d == len(b):
		print('YES')
	else:
		print('NO')


def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = set(map(lambda x: int(x) - 1, input().split()))
	for i in range(1, n):
		j = i
		while j > 0 and a[j] < a[j - 1]:
			if j - 1 in p:
				(a[j], a[j - 1]) = (a[j - 1], a[j])
			else:
				return False
			j -= 1
	return True
t = int(input())
for _ in range(t):
	if solve():
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	P = list(map(int, input().split()))
	ans = []
	for i in range(n - 1):
		for j in range(0, n - 1 - i):
			if A[j] > A[j + 1]:
				temp = A[j]
				A[j] = A[j + 1]
				A[j + 1] = temp
				if not j + 1 in ans:
					ans.append(j + 1)
	f = set(ans) & set(P)
	if len(f) == len(ans):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar1 = list(map(int, input().split()))
	for i in range(n):
		for j in ar1:
			if ar[j - 1] > ar[j]:
				(ar[j - 1], ar[j]) = (ar[j], ar[j - 1])
	if ar == sorted(ar):
		print('YES')
	else:
		print('NO')


from operator import le

def minmax(a, b):
	if a < b:
		return (a, b)
	return (b, a)

def is_sorted(a):
	return all(map(le, a[:-1], a[1:]))
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for _ in range(n):
		for i in p:
			(a[i - 1], a[i]) = minmax(a[i - 1], a[i])
	if is_sorted(a):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = [0] + [int(x) for x in input().split()]
	h = []
	for i in range(1, n + 1):
		h.append((arr[i], i))
	h = sorted(h)
	s = [0]
	for i in range(0, len(h)):
		s.append(h[i][1])
	p = [int(x) for x in input().split()]
	pos = [0] * (n + 2)
	kk = dict()
	for i in range(0, len(p)):
		kk[p[i]] = 1
	for i in range(1, len(s)):
		if s[i] != i:
			if s[i] > i:
				pos[i] += 1
				pos[s[i]] -= 1
			else:
				pos[s[i]] += 1
				pos[i] -= 1
	for i in range(2, len(pos)):
		pos[i] = pos[i] + pos[i - 1]
	temp = 'YES'
	for i in range(0, len(pos)):
		if pos[i] > 0 and kk.get(i) == None:
			temp = 'NO'
			break
	print(temp)


def solve(n, m, a, p):
	for i in range(n):
		for j in p:
			if a[j - 1] > a[j]:
				(a[j - 1], a[j]) = (a[j], a[j - 1])
	if a == sorted(a):
		return 'YES'
	return 'NO'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().strip().split()))[:n]
	p = sorted(list(map(int, input().strip().split()))[:n])
	print(solve(n, m, a, p))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = sorted(list(map(int, input().split())))
	for _ in range(100):
		for i in p:
			if arr[i - 1] > arr[i]:
				(arr[i - 1], arr[i]) = (arr[i], arr[i - 1])
	if sorted(arr) == arr:
		print('YES')
	else:
		print('NO')


import sys
import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	a = list(l)
	a.sort()
	flg = 0
	for i in range(n - 1):
		for j in range(n - i - 1):
			if l[j] > l[j + 1]:
				if j + 1 in p:
					(l[j], l[j + 1]) = (l[j + 1], l[j])
	if a != l:
		flg = 1
	if flg:
		print('NO')
	else:
		print('YES')


from sys import stdin
t = int(stdin.readline().rstrip())
for i in range(t):
	(n, m) = [int(x) for x in stdin.readline().rstrip().split()]
	a = [int(x) for x in stdin.readline().rstrip().split()]
	p = [int(x) for x in stdin.readline().rstrip().split()]
	d = sorted(a)
	for _ in range(100):
		for j in p:
			j -= 1
			if a[j] > a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if a == d:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		p = list(map(int, input().split()))
		check = sorted(a.copy())
		for i in range(n):
			for j in range(n):
				for c in p:
					if a[c - 1] > a[c]:
						(a[c - 1], a[c]) = (a[c], a[c - 1])
		ans = 'YES'
		for i in range(n):
			if a[i] != check[i]:
				ans = 'NO'
				break
		print(ans)
main()


def prep(val):
	global index
	index += 1
	return (val, index)
tests = int(input())
for _ in range(tests):
	index = 0
	(size1, size2) = map(int, input().split())
	array = sorted(map(lambda x: prep(int(x)), input().split()))
	(graph, nope) = (set(), False)
	for z in map(lambda y: int(y), input().split()):
		graph.add(z)
	for (j, k) in enumerate(array):
		if j + 1 != k[1]:
			(start, stop) = (min(j + 1, k[1]), max(j + 1, k[1]))
			for h in range(start, stop):
				if h not in graph:
					nope = True
					break
			if nope:
				break
	print('YES' if not nope else 'NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	flag = True
	while flag:
		flag = False
		for i in p:
			if a[i - 1] > a[i]:
				(a[i - 1], a[i]) = (a[i], a[i - 1])
				flag = True
	nax = a[0]
	flag2 = True
	for i in range(1, n):
		if nax > a[i]:
			flag2 = False
		nax = max(nax, a[i])
	if flag2:
		print('YES')
	else:
		print('NO')


t = int(input().strip())

def find_index(target, nums, fro, n):
	for i in range(fro, n):
		if nums[i] == target:
			return i

def can_reach(fro, to, ps, nums):
	while fro != to:
		if fro - 1 in ps:
			temp = nums[fro - 1]
			nums[fro - 1] = nums[fro]
			nums[fro] = temp
			fro -= 1
		else:
			return False
	return True
for _ in range(t):
	(n, m) = map(int, input().strip().split())
	nums = [int(i) for i in input().strip().split()]
	ps = [int(i) - 1 for i in input().strip().split()]
	num_sort = sorted(nums)
	ps.sort()
	has = True
	for (cnt, i) in enumerate(num_sort):
		index = find_index(i, nums, cnt, n)
		if nums == num_sort:
			break
		result = can_reach(index, cnt, ps, nums)
		if not result:
			has = False
			break
	if has:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	changes = -1
	while changes != 0:
		changes = 0
		for j in range(m):
			if a[p[j] - 1] > a[p[j]]:
				(a[p[j] - 1], a[p[j]]) = (a[p[j]], a[p[j] - 1])
				changes += 1
	err = False
	for j in range(n - 1):
		err = err or a[j] > a[j + 1]
	print('NO' if err else 'YES')


def che(arr, n, l):
	for i in range(0, n - 1):
		if arr[i] > arr[i + 1]:
			if l[i + 1] == 1:
				(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
			else:
				return False
	return True
t = int(input())
for i in range(t):
	(n, m) = input().strip().split(' ')
	(n, m) = [int(n), int(m)]
	a = list(map(int, input().strip().split(' ')))
	f = list(map(int, input().strip().split(' ')))
	x = [0 for _ in range(102)]
	for i in f:
		x[i] = 1
	for i in range(n - 1):
		ff = che(a, n, x)
		ff &= a[i] <= a[i + 1]
	if che(a, n, x):
		print('YES')
	else:
		print('NO')


import sys

def change(nums, P):
	result = nums.copy()
	for pos in P:
		if result[pos] > result[pos + 1]:
			(result[pos], result[pos + 1]) = (result[pos + 1], result[pos])
	return result
N = int(sys.stdin.readline())
for _ in range(N):
	l = sys.stdin.readline().split()
	length = int(l[0])
	lengthP = int(l[1])
	nums = [int(i) for i in sys.stdin.readline().split()]
	target = sorted(nums)
	P = [int(i) - 1 for i in sys.stdin.readline().split()]
	P.sort()
	result = change(nums, P)
	while not result == nums:
		nums = result
		result = change(nums, P)
	if nums == target:
		print('YES')
	else:
		print('NO')


t = int(input(''))
while t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	for i in range(n - 1):
		flag = 0
		if a == sorted(a):
			print('YES')
			flag = 1
			break
		for j in range(n - 1):
			if a[j] > a[j + 1] and j + 1 in b:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if flag == 0 and a == sorted(a):
		print('YES')
	elif flag == 1:
		pass
	else:
		print('NO')
	t -= 1


def f(a, p):
	for j in range(n):
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				if i + 1 not in p:
					return 'NO'
				else:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
	return 'YES'
t = int(input())
for __ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(y) for y in input().split()]
	p = set([int(z) for z in input().split()])
	print(f(a, p))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(lambda x: int(x) - 1, input().split()))
	b = sorted(a)
	c = a.copy()
	while True:
		for i in p:
			if a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
		if a == b:
			print('YES')
			break
		if a == c:
			print('NO')
			break
		c = a.copy()


import math
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a1 = a.copy()
	a1.sort()
	index = []
	for i in range(n):
		index.append(a.index(a1[i]) + 1)
		a[a.index(a1[i])] = -1
	real = [i + 1 for i in range(n)]
	xx = []
	for i in range(n):
		mmm = abs(real[i] - index[i])
		for j in range(mmm):
			xx.append(min(real[i], index[i]) + j)
	s = list(set(xx))
	c = 0
	for j in range(len(s)):
		if s[j] in b:
			c += 1
	if c == len(s):
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = input().split()
	p = input().split()
	for i in range(n):
		a[i] = int(a[i])
	visited = [0 for i in range(n)]
	for i in range(m):
		visited[int(p[i])] = 1
	ls = []
	temp = []
	for i in range(n):
		if visited[i] == 0:
			temp.sort()
			for j in range(len(temp)):
				ls.append(temp[j])
			temp = [a[i]]
		else:
			temp.append(a[i])
	temp.sort()
	for j in range(len(temp)):
		ls.append(temp[j])
	a.sort()
	if a == ls:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
import math

def solve(n, m, p, a):
	for cnt in range(n):
		for i in range(m):
			u = p[i] - 1
			if a[u] > a[u + 1]:
				tmp = a[u]
				a[u] = a[u + 1]
				a[u + 1] = tmp
	for i in range(n):
		if a[i] > a[i + 1]:
			return 'NO'
	return 'YES'
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	x = input()
	y = input()
	a = [int(i) for i in x.split()]
	a += [100]
	p = [int(i) for i in y.split()]
	print(solve(n, m, p, a))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	P = list(map(int, input().split()))
	for _ in range(m):
		for i in P:
			if A[i - 1] > A[i]:
				(A[i - 1], A[i]) = (A[i], A[i - 1])
	print('YES' if A == sorted(A) else 'NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	prr = list(map(int, input().split()))
	brr = [i for i in arr]
	brr.sort()
	prr = [i - 1 for i in prr]
	flag = 1
	while flag == 1:
		flag = 0
		for i in prr:
			if arr[i] > arr[i + 1]:
				t = arr[i]
				arr[i] = arr[i + 1]
				arr[i + 1] = t
				flag = 1
	if arr == brr:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	(n, m) = map(int, input().split())
	vals = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	pos.sort()
	seg = []
	left = 0
	right = 0
	for s in range(1, m):
		if pos[s - 1] + 1 == pos[s]:
			right = s
		else:
			seg.append((pos[left], pos[right] + 1))
			left = s
			right = s
	if len(seg) == 0:
		seg.append((pos[left], pos[right] + 1))
	elif seg[-1][1] != pos[m - 1]:
		seg.append((pos[left], pos[right] + 1))
	ans = vals.copy()
	for s in range(len(seg)):
		intv = seg[s]
		l = intv[0] - 1
		r = intv[1]
		temp = vals[l:r]
		temp.sort()
		for b in range(len(temp)):
			ans[b + l] = temp[b]
	sorts = vals.copy()
	sorts.sort()
	broke = False
	for s in range(n):
		if ans[s] == sorts[s]:
			continue
		else:
			broke = True
			break
	if broke == False:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = list([int(x) for x in input().split()])
	p = list([int(x) for x in input().split()])
	b = sorted(a)
	f = 0
	for k in range(n):
		for j in range(n - k - 1):
			if a[j] > a[j + 1] and j + 1 in p:
				tmp = a[j]
				a[j] = a[j + 1]
				a[j + 1] = tmp
	if b == a:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	m = [0] * n
	for i in range(n - 1):
		j = 0
		while j < n - i - 1:
			if a[j + 1] < a[j]:
				m[j + 1] = 1
				(a[j + 1], a[j]) = (a[j], a[j + 1])
			j += 1
	for x in p:
		m[x] = 0
	print('YNEOS'[sum(m) != 0::2])


cases = int(input())
for _ in range(cases):
	(n, m) = map(int, input().split())
	nums = list(map(int, input().split()))
	s = list(map(int, input().split()))
	get = True
	for i in range(len(nums)):
		for j in range(len(nums) - 1):
			if nums[j] > nums[j + 1]:
				if j + 1 not in s:
					get = False
				if get:
					(nums[j + 1], nums[j]) = (nums[j], nums[j + 1])
	if get:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for tt in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	a = list(map(int, input().split()))
	d = {i - 1: 1 for i in a}
	lsort = sorted(l)
	flag = True
	check = set()
	for i in range(n):
		if l[i] != lsort[i] or i in check:
			for j in range(n):
				if l[i] == lsort[j] and j not in check:
					ind = j
					check.add(j)
					break
			if ind >= i:
				for k in range(i, ind):
					if k not in d:
						flag = False
			else:
				for k in range(ind, i):
					if k not in d:
						flag = False
		else:
			check.add(i)
	if flag:
		print('YES')
	else:
		print('NO')


def main():
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	indices = set(list(map(int, input().split())))
	for _ in range(len(arr) - 1):
		for i in range(len(arr) - 1):
			if arr[i] > arr[i + 1]:
				if i + 1 in indices:
					(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
				else:
					print('NO')
					return
	print('YES')
	return
t = int(input())
while t:
	main()
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = [*map(int, input().split())]
	arr = set(map(int, input().split()))
	predic = False
	cnt = 0
	while True:
		flag = False
		for i in range(n - 1):
			if l[i] > l[i + 1] and i + 1 in arr:
				(l[i], l[i + 1]) = (l[i + 1], l[i])
				flag = True
			cnt += 1
		flag1 = True
		if not flag:
			for i in range(n - 1):
				if l[i] <= l[i + 1] and flag1:
					flag1 = True
				else:
					flag1 = False
					break
			if flag1:
				predic = True
				break
		if not flag and flag1 or cnt >= 10 ** 4:
			break
	if predic:
		print('YES')
	else:
		print('NO')


t = int(input())
ans = []
for i in range(t):
	(n, m) = map(int, input().split())
	ls1 = list(map(int, input().split()))
	ls2 = list(map(int, input().split()))
	flag = 0
	for k in range(len(ls1) - 1):
		for j in range(len(ls1) - k - 1):
			if ls1[j] > ls1[j + 1]:
				if j + 1 in ls2:
					temp = ls1[j + 1]
					ls1[j + 1] = ls1[j]
					ls1[j] = temp
					continue
				else:
					flag = 1
					ans.append('NO')
					break
		if flag == 1:
			break
	if flag == 0:
		ans.append('YES')
for l in range(t):
	print(ans[l])


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	P = set(map(int, input().split()))
	flag = 1
	for i in range(n):
		top = i
		for j in range(n - 1, i, -1):
			if A[i] > A[j]:
				top = j + 1
				break
		for j in range(i + 1, top):
			if j in P:
				continue
			else:
				flag = 0
				break
		if flag == 0:
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	P = list(map(int, input().split()))
	P = set([p - 1 for p in P])
	for j in range(105):
		for i in range(n - 1):
			if i in P:
				if A[i] > A[i + 1]:
					(A[i], A[i + 1]) = (A[i + 1], A[i])
	for i in range(n - 1):
		if A[i] > A[i + 1]:
			break
	else:
		print('YES')
		continue
	print('NO')


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(n, m) = map(int, sys.stdin.readline().split())
	list_a = list(map(int, sys.stdin.readline().split()))
	list_a_s = sorted(list_a)
	list_p = list(map(int, sys.stdin.readline().split()))
	cani = [0] * (n + 2)
	for nump in list_p:
		cani[nump - 1] = 1
	result = 'YES'
	end = 0
	for i in range(n - 1):
		if not list_a_s[i] == list_a[i]:
			j = i + 1
			end = 1
			while cani[j - 1]:
				if list_a[j] == list_a_s[i]:
					(list_a[i], list_a[j]) = (list_a[j], list_a[i])
					end = 0
					break
				j += 1
		if end:
			result = 'NO'
			break
	print(result)


for _ in ' ' * int(input()):
	z = lambda : map(int, input().split())
	(a, b) = z()
	c = list(z())
	d = list(z())
	for _ in range(b):
		for i in d:
			if c[i] < c[i - 1]:
				(c[i], c[i - 1]) = (c[i - 1], c[i])
	print('YES' if sorted(c) == c else 'NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = sorted(list(map(int, input().split())))
	b = sorted(a)
	for _ in range(100):
		for i in range(len(p)):
			if a[p[i] - 1] > a[p[i]]:
				(a[p[i] - 1], a[p[i]]) = (a[p[i]], a[p[i] - 1])
		if a == b:
			print('YES')
			break
	else:
		print('NO')


from sys import stdin, stdout

def fn(a):
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			if i + 1 in ps:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
for _ in range(int(stdin.readline())):
	(n, m) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	ps = set(map(int, stdin.readline().split()))
	b = sorted(a)
	cpy = b.copy()
	while a != cpy:
		cpy = a.copy()
		fn(a)
	print('YES' if a == b else 'NO')


from collections import Counter, defaultdict

def main():
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	pos = defaultdict(int)
	for e in p:
		pos[e - 1] = 1
	while True:
		swapped = False
		for i in range(n):
			if pos[i] and arr[i] > arr[i + 1]:
				(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
				swapped = True
		if not swapped:
			break
	for i in range(n - 1):
		if arr[i] > arr[i + 1]:
			print('NO')
			return
	print('YES')
tc = 1
tc = int(input())
for _ in range(tc):
	main()


from collections import defaultdict as dc
import sys
import math
input = sys.stdin.readline

def fun(g, l, n, f, s):
	q = [s]
	f[s] = 1
	p = []
	while q:
		x = q.pop(0)
		p.append(x)
		for i in g[x]:
			if f[i] == 0:
				q.append(i)
				f[i] = 1
	q = [l[i] for i in p]
	p.sort()
	q.sort()
	for i in range(len(p)):
		l[p[i]] = q[i]
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	g = dc(list)
	for i in p:
		g[i - 1].append(i)
		g[i].append(i - 1)
	f = [0] * n
	for i in range(n):
		if i in g.keys() and f[i] == 0:
			fun(g, l, n, f, i)
	if l == sorted(l):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	if sorted(a) == a:
		print('YES')
	else:
		flag = 1
		for i in range(len(a)):
			for j in range(len(a) - 1 - i):
				if a[j] > a[j + 1]:
					if j + 1 in p:
						(a[j], a[j + 1]) = (a[j + 1], a[j])
					else:
						flag = 0
						print('NO')
						break
			if flag == 0:
				break
		if flag:
			print('YES')


import sys

def issorted(a, n):
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			return 0
	return 1
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	check = [0 for _ in range(n)]
	for i in range(m):
		check[p[i] - 1] = 1
	for _ in range(n):
		for j in range(n - 1):
			if check[j] == 1:
				if a[j] > a[j + 1]:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
	if issorted(a, n):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	p = set([int(x) - 1 for x in input().split()])
	inversions = False
	for i in range(n - 1):
		if a[i + 1] < a[i]:
			inversions = True
	while inversions:
		i = 0
		found = False
		for i in p:
			if a[i + 1] < a[i]:
				found = True
				break
		if found:
			b = a[i + 1]
			a[i + 1] = a[i]
			a[i] = b
			inversions = False
			for i in range(n - 1):
				if a[i + 1] < a[i]:
					inversions = True
		else:
			break
	if inversions:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	pos = list(map(lambda x: int(x) - 1, input().split()))
	z = sorted(list(l))
	d = {}
	s = set(pos)
	sor = {}
	flag = 'YES'
	for i in range(n):
		d[l[i]] = i
		sor[z[i]] = i
	for i in range(n):
		for j in range(min(d[l[i]], sor[l[i]]), max(d[l[i]], sor[l[i]])):
			if j not in s:
				flag = 'NO'
	print(flag)


from math import *
from collections import *
t = int(input())
for y in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	ans = a[:p[0] - 1]
	i = 0
	while i < m:
		st = i
		while i < m - 1 and p[i] + 1 == p[i + 1]:
			i += 1
		x = a[p[st] - 1:p[i] + 1]
		ans.extend(sorted(x))
		if i < m - 1:
			ans.extend(a[p[i] + 1:p[i + 1] - 1])
		else:
			ans.extend(a[p[i] + 1:])
		i += 1
	if ans == sorted(ans):
		print('YES')
	else:
		print('NO')


import sys
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	for i in range(n):
		if sorted(a) != a:
			for j in p:
				if a[j - 1] > a[j]:
					(a[j - 1], a[j]) = (a[j], a[j - 1])
		else:
			break
	if sorted(a) == a:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(lambda x: int(x) - 1, input().split()))
	while True:
		swapped = False
		for i in p:
			if a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				swapped = True
		if not swapped:
			break
	result = 'YES'
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			result = 'NO'
			break
	print(result)


t = int(input())
while t != 0:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	v = []
	count = 1
	while count != 0:
		count = 0
		for i in range(n - 1):
			if a[i + 1] < a[i]:
				count += 1
				v.append(i + 1)
				temp = a[i]
				a[i] = a[i + 1]
				a[i + 1] = temp
	ans = True
	for i in v:
		if i not in p:
			ans = False
			break
	if ans:
		print('YES')
	else:
		print('NO')


def swap(i):
	temp = a[i]
	a[i] = a[i + 1]
	a[i + 1] = temp
	return a
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	b = sorted(a)
	ans = 'YES'
	while ans == 'YES' and a != b:
		for i in range(n - 1):
			if a[i] > a[i + 1] and i + 1 in p:
				a = swap(i)
			elif a[i] > a[i + 1]:
				ans = 'NO'
	print(ans)


p = []
a = []

def rec():
	old = a[:]
	for x in p:
		a[x - 1:x + 1] = sorted(a[x - 1:x + 1])
	if a == old:
		return 1
	else:
		return 0
t = int(input())
for t_itr in range(t):
	nm = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	a_s = sorted(a)
	f = 0
	while 1:
		f = rec()
		if a == a_s:
			print('YES')
			break
		if f:
			print('NO')
			break


t = int(input())
for r in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	d = {}
	for i in p:
		d[i - 1] = 0
	for i in range(n - 1):
		for j in range(n - 1):
			try:
				if d[j] == 0:
					if l[j] > l[j + 1]:
						(l[j], l[j + 1]) = (l[j + 1], l[j])
			except:
				pass
	a = sorted(l)
	if a == l:
		print('YES')
	else:
		print('NO')


def fun(a, n, q):
	for i in range(0, n - 1):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
				q[j + 1] = 0
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(n) for n in input().split()]
	p = [int(n) for n in input().split()]
	y = {}
	for i in p:
		y[i] = 0
	q = {}
	fun(a, n, q)
	f = 0
	for i in q:
		if i not in y:
			f = 1
			break
	if f == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l2 = [0] * n
	for j in range(len(l1)):
		l2[l1[j] - 1] = 1
	ind = 0
	l3 = []
	for j in range(len(l2)):
		if l2[j] == 0:
			l4 = l[ind:j + 1]
			ind = j + 1
			l4.sort()
			l3 = l3 + l4
	for j in range(1, n):
		if l3[j] < l3[j - 1]:
			print('NO')
			break
		elif j == n - 1:
			print('YES')


t = int(input())
while t > 0:
	(n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	p = [int(i) - 1 for i in input().split()]
	flag = 1
	for i in range(n - 1):
		m = 101
		mind = 0
		for j in range(i, n):
			if a[j] < m:
				m = a[j]
				mind = j
		while mind - 1 in p and mind - 1 >= i:
			(a[mind], a[mind - 1]) = (a[mind - 1], a[mind])
			mind -= 1
		if mind != i:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')
	t -= 1


import sys, bisect
input = sys.stdin.readline
t = int(input())
for testcase in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	b = sorted(a)
	flag = True
	for i in range(n):
		e = a[i]
		k1 = bisect.bisect_left(b, e)
		k2 = bisect.bisect_right(b, e) - 1
		if k1 <= i <= k2:
			continue
		if k1 > i:
			q1 = bisect.bisect_left(p, k1)
			q2 = bisect.bisect_left(p, i + 1)
			if not 0 <= q1 < m:
				flag = False
				break
			if not 0 <= q2 < m:
				flag = False
				break
			if k1 - (i + 1) != q1 - q2 or p[q1] != k1 or p[q2] != i + 1:
				flag = False
				break
		elif k2 < i:
			q1 = bisect.bisect_left(p, i)
			q2 = bisect.bisect_left(p, k2 + 1)
			if not 0 <= q1 < m:
				flag = False
				break
			if not 0 <= q2 < m:
				flag = False
				break
			if i - (k2 + 1) != q1 - q2 or p[q1] != i or p[q2] != k2 + 1:
				flag = False
				break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	p = [int(x) - 1 for x in input().split()]
	p = set(p)
	b = sorted(a)
	minWrong = -1
	maxWrong = -1
	for j in range(n - 1):
		for i in range(n - 1):
			if a[i] > a[i + 1] and i in p:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
	if a == b:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	k = input()
	(n, p) = k.split(' ')
	ni = input()
	ni = ni.split(' ')
	pi = input()
	pi = pi.split(' ')
	listaNi = []
	listaPi = []
	for i in range(len(ni)):
		listaNi.append(int(ni[i]))
	for i in range(len(pi)):
		listaPi.append(int(pi[i]))
	ordenarNi = sorted(listaNi)
	aux = 0
	flag = 0
	p = 0
	while True:
		for i in range(len(listaPi)):
			if listaNi[listaPi[i]] < listaNi[listaPi[i] - 1]:
				aux = listaNi[listaPi[i] - 1]
				listaNi[listaPi[i] - 1] = listaNi[listaPi[i]]
				listaNi[listaPi[i]] = aux
			if ordenarNi == listaNi:
				flag = 1
				break
		if flag == 1 or p == len(listaPi):
			break
		p = p + 1
	if ordenarNi == listaNi:
		print('YES')
	else:
		print('NO')


def WeirdSort(a, p):
	while True:
		original = a[0:]
		for j in p:
			key = a[j]
			i = j - 1
			if i >= 0 and a[i] > key:
				a[i + 1] = a[i]
				a[i] = key
		if original == a:
			break
	if a == sorted(a):
		res = 'YES'
	else:
		res = 'NO'
	return res
q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	result = WeirdSort(a, p)
	print(result)


t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	pos = [int(x) for x in input().split()]
	p = [0] * n
	for i in pos:
		p[i - 1] = 1
	while True:
		ok = False
		for i in range(n):
			if p[i] and a[i] > a[i + 1]:
				ok = True
				(a[i], a[i + 1]) = (a[i + 1], a[i])
		if not ok:
			break
	ok = True
	for i in range(n - 1):
		ok &= a[i] <= a[i + 1]
	if ok:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	ch = list(l)
	ch.sort()
	p = list(map(int, input().split()))
	p.sort(reverse=True)
	ch2 = list(l)
	while True:
		for i in p:
			i -= 1
			if l[i] > l[i + 1]:
				(l[i], l[i + 1]) = (l[i + 1], l[i])
		if ch2 != l:
			ch2 = list(l)
		else:
			break
	if ch == l:
		print('YES')
	else:
		print('NO')


from pprint import pprint
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	data = list(map(int, input().split()))
	datp = list(map(int, input().split()))
	canchange = [False] * 2000
	for i in range(len(datp)):
		canchange[datp[i] - 1] = True
	f = True
	while True:
		nochange = True
		for i in range(n - 1):
			if data[i] > data[i + 1]:
				if canchange[i]:
					(data[i], data[i + 1]) = (data[i + 1], data[i])
					nochange = False
				else:
					nochange = True
					f = False
					break
		if nochange:
			break
	print('YES' if f else 'NO')


numbers = []

def swap(a, b):
	t = numbers[a]
	numbers[a] = numbers[b]
	numbers[b] = t
cases = int(input())
for case in range(cases):
	(n, m) = map(int, input().split())
	numbers = list(map(int, input().split()))
	oper = list(map(int, input().split()))
	oper.sort()
	oper.reverse()
	for i in range(n):
		for j in range(m):
			if numbers[oper[j] - 1] > numbers[oper[j]]:
				swap(oper[j] - 1, oper[j])
	if numbers == sorted(numbers):
		print('YES')
	else:
		print('NO')


import sys, math

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split())) + [10000]
		p = set(map(int, input().split()))
		L = []
		temp = [a[0]]
		for k in range(1, n + 1):
			if k in p:
				temp.append(a[k - 1])
				temp.append(a[k])
			else:
				L.append(temp)
				temp = [a[k]]
		f = 1
		for k in range(len(L) - 1):
			if max(L[k]) > min(L[k + 1]):
				f = 0
				break
		if f == 1:
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = l1.copy()
	for i in range(m):
		for j in range(m):
			if l2[j] != n:
				if l1[l2[j] - 1] > l1[l2[j]]:
					t = l1[l2[j] - 1]
					l1[l2[j] - 1] = l1[l2[j]]
					l1[l2[j]] = t
	l3.sort()
	if l1 == l3:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	notSorted = True
	while True:
		notSorted = False
		swapped = False
		for i in p:
			i -= 1
			if a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				swapped = True
		if swapped:
			continue
		a_sorted = True
		for j in range(1, len(a)):
			if a[j] < a[j - 1]:
				a_sorted = False
				break
		if a_sorted:
			print('YES')
		else:
			print('NO')
		break


t = int(input())
while t:
	input()
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	swappable = [False] * len(a)
	for i in p:
		swappable[i - 1] = True
	while True:
		c = False
		for i in range(len(a)):
			if swappable[i] and a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				c = True
		if not c:
			break
	s = True
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			s = False
			break
	print('YES') if s else print('NO')
	t -= 1


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(l, ps, n, t):
	for i in range(n - l + 1):
		if ps[i + l] - ps[i] <= t:
			return True
	return False
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	(m, n) = read()
	a = list(read())
	p = list(read())
	for x in range(n):
		for i in p:
			(a[i - 1], a[i]) = (min(a[i - 1], a[i]), max(a[i - 1], a[i]))
	print(['NO', 'YES'][a == sorted(a)])
for _ in range(int(input())):
	solve()


import sys
import bisect
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter as c
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(var)

def l():
	return list(map(int, data().split()))

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
for _ in range(int(data())):
	(n, m) = sp()
	a = l()
	p = l()
	result = True
	for i in range(n - 1):
		for j in range(n - i - 1):
			if a[j] > a[j + 1]:
				if j + 1 in p:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
				else:
					result = False
					break
		if not result:
			break
	if result:
		print('YES')
		continue
	print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	p.sort()
	i = 0
	while i < m:
		temp = p[i]
		k = i + 1
		while k < m:
			if p[k] != temp + 1:
				break
			else:
				temp = p[k]
			k += 1
		arr[p[i] - 1:p[k - 1] + 1] = sorted(arr[p[i] - 1:p[k - 1] + 1])
		i = k
	if arr == sorted(arr):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	a1 = sorted(a)
	p = [i - 1 for i in p]
	f = 0
	while True:
		c = 0
		for i in p:
			if a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				c += 1
		if c == 0 or a == a1:
			break
	if a == a1:
		print('YES')
	else:
		print('NO')


def compute(n, m, arr, p_m):
	count = m
	while m > 0:
		for i in p_m:
			if arr[i - 1] > arr[i]:
				(arr[i - 1], arr[i]) = (arr[i], arr[i - 1])
		m -= 1
	for i in range(n - 1):
		if i == n - 2 and arr[i] <= arr[i + 1]:
			return 'YES'
		elif arr[i] > arr[i + 1]:
			break
	return 'NO'
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p_m = list(map(int, input().split()))
	print(compute(n, m, arr, p_m))


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, M) = MAP()
	A = LIST()
	B = LIST()
	is_ok = [0] * N
	for b in B:
		is_ok[b] = 1
	tmp = [A[0]]
	A2 = []
	for (i, a) in enumerate(A[1:], 1):
		if is_ok[i]:
			tmp.append(a)
		else:
			tmp.sort()
			A2.extend(tmp)
			tmp = [a]
	tmp.sort()
	A2.extend(tmp)
	for i in range(N - 1):
		if A2[i] > A2[i + 1]:
			NO()
			break
	else:
		YES()


try:
	t = int(input())
	for i in range(t):
		x = list(map(int, input().split()))
		a = list(map(int, input().split()))
		p = list(map(int, input().split()))
		w = []
		n = len(a)
		Q = []
		for i in range(n):
			for j in range(0, n - i - 1):
				if a[j] > a[j + 1]:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
					Q.append(j)
		if len(Q) == 0:
			print('YES')
			continue
		for i in range(len(p)):
			w.append(p[i] - 1)
		m = set(Q)
		n = set(w)
		if m.issubset(n):
			print('YES')
		else:
			print('NO')
except:
	pass


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	l = a.copy()
	p = list(map(int, input().split()))
	p.sort(reverse=True)
	for i in range(0, m):
		p[i] = p[i] - 1
	for j in range(0, 120):
		for i in range(0, m):
			if p[i] != n - 1 and a[p[i]] > a[p[i] + 1]:
				w = a[p[i]]
				a[p[i]] = a[p[i] + 1]
				a[p[i] + 1] = w
	l.sort()
	if l == a:
		print('YES')
	else:
		print('NO')


t = int(input())
output = []
for _ in range(t):
	l = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	while True:
		swapped = False
		for pos in p:
			if a[pos - 1] > a[pos]:
				tmp = a[pos - 1]
				a[pos - 1] = a[pos]
				a[pos] = tmp
				swapped = True
		if swapped == False:
			break
	sort = True
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			sort = False
			output.append('NO')
			break
	if sort == True:
		output.append('YES')
for o in output:
	print(o)


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	ai = list(map(int, input().split()))
	pi = list(map(int, input().split()))
	flag = 0
	for i in range(n):
		Min = 100
		index = -1
		for j in range(i, n):
			if index == -1:
				Min = ai[j]
				index = j
			elif ai[j] < Min:
				Min = ai[j]
				index = j
		while index > 0 and ai[index - 1] > ai[index]:
			if index in pi:
				temp = ai[index]
				ai[index] = ai[index - 1]
				ai[index - 1] = temp
				index -= 1
			else:
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


import sys
input_file = sys.stdin
output_file = sys.stdout
t = int(input_file.readline())
for t in range(t):
	(n, m) = map(int, input_file.readline().split())
	a = list(map(int, input_file.readline().split()))
	p = list(map(int, input_file.readline().split()))
	p.sort()
	for it in range(n):
		for pos in p:
			if a[pos - 1] > a[pos]:
				(a[pos - 1], a[pos]) = (a[pos], a[pos - 1])
	b = sorted(a.copy())
	if a == b:
		output_file.write('YES\n')
	else:
		output_file.write('NO\n')


t = int(input())
for q in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	tab = [0] * 101
	for i in range(len(p)):
		tab[p[i] - 1] = 1
	temp = 0
	for i in range(n):
		for j in range(n - 1):
			if arr[j] > arr[j + 1] and tab[j] == 1:
				temp = arr[j]
				arr[j] = arr[j + 1]
				arr[j + 1] = temp
		temp = 0
	flag = 0
	for i in range(len(arr) - 1):
		if arr[i] > arr[i + 1]:
			flag = 1
	if flag == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin
num = int(input())
for i in range(num):
	(len, allowed) = map(int, input().split())
	a = [int(x) for x in stdin.readline().rstrip().split()]
	p = [int(x) for x in stdin.readline().rstrip().split()]
	sorted = a.copy()
	sorted.sort()
	while a != sorted:
		flag = False
		for j in range(allowed):
			if a[p[j] - 1] > a[p[j]]:
				flag = True
				temp = a[p[j] - 1]
				a[p[j] - 1] = a[p[j]]
				a[p[j]] = temp
		if not flag:
			print('NO')
			break
	if a == sorted:
		print('YES')


import sys
import math
import operator as op
from functools import reduce

def read_line():
	return sys.stdin.readline()[:-1]

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

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def read_float_line():
	return [float(v) for v in sys.stdin.readline().split()]

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
t = read_int()
for i in range(t):
	(n, m) = read_int_line()
	a = read_int_line()
	b = read_int_line()
	p = {}
	for i in b:
		p[i - 1] = 1
	for i in range(n):
		for j in range(n - 1):
			if a[j] > a[j + 1] and j in p:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	f = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time

def I():
	return int(input())

def MI():
	return map(int, input().split())

def S():
	return input()

def MS():
	return map(str, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def input():
	return sys.stdin.readline().rstrip()

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = {False: 'NO', True: 'YES'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False

def solve(T):
	(n, m) = MI()
	a = LI()
	p = LI()
	dic = {k: True for k in p}
	for i in range(n):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1]:
				if j + 1 not in dic:
					print('NO')
					return
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	print('YES')

def main():
	T = I()
	for i in range(T):
		solve(T)
main()


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 1000000007

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

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

def main():
	(n, m) = vars()
	arr = array()
	ans = sorted(arr)
	p = array()
	p.sort()
	segment = []
	for i in range(m):
		if segment and p[i] - 1 == segment[-1][1]:
			segment[-1][1] = p[i]
		else:
			segment.append([p[i] - 1, p[i]])
	for (l, r) in segment:
		arr[l:r + 1] = sorted(arr[l:r + 1])
	if arr == ans:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	main()


t = int(input())
while t:
	(n, m) = input().split()
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	while True:
		flag1 = 0
		flag2 = 0
		for i in range(len(arr) - 1):
			if arr[i] > arr[i + 1]:
				flag1 = 1
				if i + 1 in p:
					flag2 = 1
					(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
		if flag1 == 0 and flag2 == 0:
			print('YES')
			break
		elif flag1 == 1 and flag2 == 0:
			print('NO')
			break
	t -= 1


def solve(arr, swaps, n, m, ans):
	while True:
		found = False
		for i in range(n - 1):
			if arr[i] > arr[i + 1]:
				if i + 1 in swaps:
					found = True
					(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
		if not found:
			break
	for i in range(n - 1):
		if arr[i] > arr[i + 1]:
			ans.append('NO')
			return
	ans.append('YES')

def main():
	ans = []
	t = int(input())
	for i in range(t):
		(n, m) = map(int, input().split())
		arr = list(map(int, input().split()))
		swaps = set(map(int, input().split()))
		solve(arr, swaps, n, m, ans)
	for i in ans:
		print(i)
main()


t = int(input())
for test in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	p.sort()
	x = sorted(a)
	y = [0 for i in range(n)]
	pr = {}
	for i in range(n):
		ind = x.index(a[i])
		while y[ind] != 0:
			ind += 1
		if y[ind] == 0:
			if ind < i:
				for j in range(ind, i):
					pr[j + 1] = pr.get(j + 1, 0)
			else:
				for j in range(i, ind):
					pr[j + 1] = pr.get(j + 1, 0)
			y[ind] = 1
	xx = sorted(list(pr.keys()))
	if len(xx) == 0:
		print('YES')
		continue
	ff = 0
	for i in range(len(xx)):
		if xx[i] in p:
			continue
		else:
			ff = 1
	if ff == 1:
		print('NO')
	else:
		print('YES')


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))

def removeall_replace(element, lst):
	t = [y for y in lst if y != element]
	del lst[:]
	lst.extend(t)
for _ in range(get_int()):
	(n, p) = get_int_list()
	arr = get_int_list()
	index = set(get_int_list())
	flag = True
	while flag:
		flag = False
		for i in range(n - 1):
			if arr[i] > arr[i + 1] and i + 1 in index:
				(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
				flag = True
	non_dec = True
	for i in range(n - 1):
		if arr[i] > arr[i + 1]:
			non_dec = False
			break
	if non_dec:
		print('YES')
	else:
		print('NO')


from copy import *
t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p = deepcopy(p)
	SORTED = sorted(a)
	for j in range(len(a)):
		for k in range(len(p)):
			if a[p[k] - 1] > a[p[k]]:
				temp = a[p[k] - 1]
				a[p[k] - 1] = a[p[k]]
				a[p[k]] = temp
	if a == SORTED:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	mylist = list(map(int, input().split()))
	mylist2 = list(map(int, input().split()))
	for i in range(x):
		for j in mylist2:
			if mylist[j - 1] > mylist[j]:
				temp = mylist[j - 1]
				mylist[j - 1] = mylist[j]
				mylist[j] = temp
	w = list(mylist)
	w.sort()
	flag = True
	for i in range(x):
		if mylist[i] != w[i]:
			flag = False
			break
	print('YES' if flag == True else 'NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	sorted(arr2)
	for k in range(n):
		for j in arr2:
			if arr1[j - 1] > arr1[j]:
				(arr1[j - 1], arr1[j]) = (arr1[j], arr1[j - 1])
	if arr1 == sorted(arr1):
		print('YES')
	else:
		print('NO')


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

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

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

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

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

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

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for _ in range(Int()):
		(n, m) = Mint()
		a = List()
		p = List()
		b = sorted(a)
		ans = []
		flag = 0
		for i in range(n):
			for j in range(n - i - 1):
				if a[j] > a[j + 1]:
					if j + 1 not in p:
						flag = 1
						break
					else:
						(a[j], a[j + 1]) = (a[j + 1], a[j])
		if flag == 1:
			print('NO')
		else:
			print('YES')
solution()


t = int(input())
for _ in range(t):
	(m, n) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	while True:
		status = True
		for i in p:
			if a[i - 1] > a[i]:
				status = False
				(a[i - 1], a[i]) = (a[i], a[i - 1])
		if status:
			break
	status2 = True
	for i in range(m - 1):
		if a[i] > a[i + 1]:
			status2 = False
			break
	if not status2:
		print('NO')
	else:
		print('YES')


import math
import sys
from collections import defaultdict, Counter
from itertools import groupby
rt = lambda : map(int, input().split())
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))

def main():
	t = ri()
	for _ in range(t):
		(n, m) = rt()
		a = rl()
		p = rl()
		max_right = [0] * n
		can_shift = [False] * n
		for pi in p:
			can_shift[pi - 1] = True
		for i in range(n - 2, -1, -1):
			if can_shift[i]:
				max_right[i] = max_right[i + 1] + 1
		pos = 0
		while pos < n:
			a[pos:pos + max_right[pos] + 1] = sorted(a[pos:pos + max_right[pos] + 1])
			pos = pos + max_right[pos] + 1
		is_sorted = True
		for i in range(n - 1):
			if a[i + 1] < a[i]:
				is_sorted = False
				break
		print('YES' if is_sorted else 'NO')
main()


def main():
	t = int(input())
	for qweqe in range(t):
		(n, a) = map(int, input().split())
		a = list(map(int, input().split()))
		p = list(map(int, input().split()))
		for i in range(1, n):
			if max(a[:i]) > min(a[i:]) and i not in p:
				print('NO')
				break
		else:
			print('YES')
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().strip().split()))[:n]
	vir = arr
	swap = list(map(int, input().strip().split()))[:k]
	from collections import defaultdict
	store = defaultdict(int)
	for s in swap:
		store[s - 1] = True
	for i in range(n):
		if store[i] == True:
			j = i
			while j < n and store[j] == True:
				j += 1
			new = sorted(arr[i:min(n, j + 1)])
			for k in range(i, min(n, j + 1)):
				arr[k] = new[k - i]
			i = j + 1
	flag = 0
	for i in range(n - 1):
		if arr[i] > arr[i + 1]:
			print('NO')
			flag = 1
			break
	if flag == 0:
		print('YES')


ans = []
for t in range(int(input())):
	[n, m] = [int(i) for i in input().split()]
	seq = [int(i) for i in input().split()]
	temp = set([int(i) - 1 for i in input().split()])
	valid = True
	go = True
	while go:
		for i in range(n):
			if i == n - 1:
				go = False
				break
			if seq[i] > seq[i + 1]:
				if i in temp:
					(seq[i], seq[i + 1]) = (seq[i + 1], seq[i])
				else:
					(valid, go) = (False, False)
				break
	if valid:
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]

def solution(a, n, p, m):
	p = set(p)
	for i in range(1, n):
		while i > 0 and a[i] < a[i - 1]:
			if i not in p:
				return 'NO'
			(a[i], a[i - 1]) = (a[i - 1], a[i])
			i -= 1
	return 'YES'

def main():
	T = read_int()
	for i in range(T):
		(n, m) = read_int_array()
		a = read_int_array()
		p = read_int_array()
		x = solution(a, n, p, m)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


t = int(input())
for queries in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	a2 = a.copy()
	a.sort()
	while a2 != a:
		changed = False
		for i in range(n - 1):
			if a2[i] > a2[i + 1] and i + 1 in p:
				a3 = a2[i]
				a2[i] = a2[i + 1]
				a2[i + 1] = a3
				changed = True
		if not changed:
			break
	if a2 == a:
		print('YES')
	else:
		print('NO')


def go():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = sorted(map(int, input().split()))
	sa = sorted(a)
	i = 0
	pp = 0
	while i < n:
		j = i
		while j < n and pp < m and (p[pp] - 1 == j):
			j += 1
			pp += 1
		if sorted(a[i:j + 1]) != sa[i:j + 1]:
			return 'NO'
		i = j + 1
	return 'YES'
t = int(input())
ans = []
for _ in range(t):
	ans.append(str(go()))
print('\n'.join(ans))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) - 1 for i in input().split()]
	asort = sorted(a)
	ind = 0
	flag = 0
	for i in range(n):
		ind = asort.index(a[i]) + a[:i].count(a[i])
		if i == ind:
			continue
		for j in range(i, ind):
			if j not in p:
				flag = 1
				print('NO')
				break
		if flag == 1:
			break
	if flag == 0:
		print('YES')


def i():
	return input()

def ii():
	return int(input())

def iis():
	return map(int, input().split())

def liis():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(n, m) = iis()
	a = liis()
	p = liis()
	can = True
	for i in range(len(p)):
		p[i] -= 1
	sa = sorted(a)
	p = sorted(p)
	spaces = []
	init = [p[0]]
	for i in p[1:]:
		if i == init[-1] + 1:
			init.append(i)
		else:
			init.append(init[-1] + 1)
			spaces.append(init)
			init = [i]
	init.append(init[-1] + 1)
	spaces.append(init)
	k = 0
	i = 0
	while i < n and can:
		if k < len(spaces) and i == spaces[k][0]:
			(begin, end) = (spaces[k][0], spaces[k][-1])
			elements = {}
			for j in range(begin, end + 1):
				if a[j] not in elements:
					elements[a[j]] = 0
				elements[a[j]] += 1
			for j in range(begin, end + 1):
				if sa[j] in elements:
					elements[sa[j]] -= 1
					if elements[sa[j]] < 0:
						can = False
						break
				else:
					can = False
					break
			i = end + 1
			k += 1
		else:
			if a[i] != sa[i]:
				can = False
			i += 1
	if can:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	(n, m) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	adjacency_list = {}
	for j in range(n):
		adjacency_list[j] = []
	for el in p:
		if el < n:
			adjacency_list[el - 1].append(el)
			adjacency_list[el].append(el - 1)
	res = 'YES'
	while True:
		change = False
		for j in range(len(a)):
			if j != 0 and a[j - 1] > a[j] and (j not in adjacency_list[j - 1]):
				res = 'NO'
				break
			elif j != 0 and a[j - 1] > a[j] and (j in adjacency_list[j - 1]):
				(a[j - 1], a[j]) = (a[j], a[j - 1])
				change = True
		if not change:
			break
	print(res)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		print('YES' if solve() else 'NO')

def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(lambda x: int(x) - 1, input().split()))
	p.sort()
	s = [0] * n
	for p1 in p:
		s[p1] = 1
		s[p1 + 1] = 2
	lmax = [0] * n
	rmin = [0] * n
	lmax[0] = a[0]
	rmin[n - 1] = a[n - 1]
	for i in range(1, n):
		lmax[i] = max(lmax[i - 1], a[i])
		rmin[n - i - 1] = min(rmin[n - i], a[n - i - 1])
	for i in range(n):
		if s[i] == 1:
			continue
		if s[i] == 2:
			if i < n - 1:
				if lmax[i] > rmin[i + 1]:
					return False
		else:
			if i > 0:
				if lmax[i - 1] > a[i]:
					return False
			if i < n - 1:
				if rmin[i + 1] < a[i]:
					return False
	return True
main()


def res(n, m, l, p):
	count = 0
	l1 = sorted(l)
	while l != l1:
		for i in p:
			if l[i - 1] > l[i]:
				(l[i - 1], l[i]) = (l[i], l[i - 1])
				count += 1
		if count == 0:
			return 'NO'
		else:
			count = 0
	return 'YES'
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	print(res(n, m, l, p))


def index(a, el):
	for i in range(len(a)):
		if a[i] == el:
			return i
	return -1
t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(len(p)):
		p[i] = p[i] - 1
	sortable = True
	for i in range(len(a)):
		minelind = i + index(a[i:], min(a[i:]))
		for j in range(minelind - 1, i - 1, -1):
			if j in p:
				temp = a[j]
				a[j] = a[j + 1]
				a[j + 1] = temp
			else:
				sortable = False
	if sortable:
		print('YES')
	else:
		print('NO')


t = int(input())
while t != 0:
	n_m = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	for i in range(n_m[0]):
		for i in range(n_m[1]):
			if a[p[i] - 1] > a[p[i]]:
				(a[p[i] - 1], a[p[i]]) = (a[p[i]], a[p[i] - 1])
	f = True
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	flag = 0
	sort_ = False
	l = list(sorted(a))
	while sort_ == False and flag == 0:
		count = 0
		for i in range(m):
			if a[p[i] - 1] > a[p[i]]:
				get = (a[p[i] - 1], a[p[i]])
				(a[p[i]], a[p[i] - 1]) = get
			else:
				count += 1
			if count == m:
				flag = 1
		sort_ = l == a
	if flag == 1 and sort_ == False:
		print('NO')
	elif sort_ == True:
		print('YES')


from bisect import *
from collections import *
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	b = list(a)
	a.sort()
	p.sort()
	d = defaultdict(lambda : 0)
	for i in p:
		d[i] = 1
	ch = 1
	for i in range(1, len(b)):
		key = b[i]
		j = i - 1
		while j >= 0 and key < b[j]:
			if d[j + 1] == 1:
				b[j + 1] = b[j]
				j -= 1
			else:
				ch = 0
				break
		b[j + 1] = key
	if ch == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(map(int, input().split()))
	p = list(map(int, input().split()))
	i = 0
	check = 1
	ans = True
	while i != len(s) - check:
		if s[i] > s[i + 1]:
			(s[i], s[i + 1]) = (s[i + 1], s[i])
			if i + 1 not in p:
				ans = False
			if i == 0:
				i -= 1
			else:
				i -= 2
		i += 1
	if ans:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t = t - 1
	(a, b) = map(int, input().split())
	ar = []
	ar.append(0)
	a = list(map(int, input().split()))
	n = len(a)
	for i in a:
		ar.append(i)
	p = list(map(int, input().split()))
	b = sorted(ar)
	for i in range(n):
		for j in range(n):
			if j in p and ar[j] > ar[j + 1]:
				temp = ar[j]
				ar[j] = ar[j + 1]
				ar[j + 1] = temp
	if ar == b:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t += -1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	check = [0] * n
	for i in p:
		check[i] = 1
	l = []
	for i in a:
		l.append(i)
	l.sort()
	x = 0
	chh = 1
	while 1:
		mn = l[x]
		ind = 0
		for i in range(x, n):
			if a[i] == mn:
				ind = i + 1
				break
		ch = 1
		for i in range(x + 1, ind):
			if check[i] != 1:
				ch = 0
				break
		if ch == 0:
			chh = 0
			break
		for i in range(ind - 1, x, -1):
			(a[i], a[i - 1]) = (a[i - 1], a[i])
		x -= -1
		if x == n:
			break
	if chh:
		print('YES')
	else:
		print('NO')


from sys import stdin
from operator import itemgetter
from bisect import *
from collections import *

def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return list(stdin.readline()[:-1])

def arr_enu():
	return [[i + 1, int(x)] for (i, x) in enumerate(stdin.readline().split())]
for i in range(int(input())):
	(n, m) = arr_inp(1)
	(a, p) = (arr_enu(), sorted(arr_inp(1)))
	mem = defaultdict(int, {p[0]: 1})
	for j in range(1, m):
		mem[p[j]] = mem[p[j - 1]] + 1
	(a1, c, ans) = (sorted(a.copy(), key=itemgetter(1, 0)), 1, 'YES')
	for (j, k) in a1:
		if a[c - 1][1] != k:
			if j >= c:
				if mem[j - 1] and mem[c]:
					if mem[j - 1] - mem[c] != j - c - 1:
						ans = 'NO'
						break
				else:
					ans = 'NO'
					break
			elif mem[j] and mem[c - 1]:
				if mem[c - 1] - mem[j] != c - j - 1:
					ans = 'NO'
					break
			else:
				ans = 'NO'
				break
		c += 1
	print(ans)


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	pos = [int(x) for x in input().split()]
	for _ in range(m):
		for x in pos:
			if a[x - 1] > a[x]:
				(a[x], a[x - 1]) = (a[x - 1], a[x])
	print('YES' if a == sorted(a) else 'NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	ln = list(map(int, input().split()))
	lm = list(map(int, input().split()))
	for i in range(n):
		for j in lm:
			if ln[j - 1] > ln[j]:
				(ln[j - 1], ln[j]) = (ln[j], ln[j - 1])
	if sorted(ln) == ln:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	swp = list(map(int, input().split()))
	for mm in range(m):
		for pos in swp:
			if arr[pos] < arr[pos - 1]:
				(arr[pos], arr[pos - 1]) = (arr[pos - 1], arr[pos])
	if sorted(arr) == arr:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	l = []
	l = l + a
	p.sort()
	for i in range(n):
		for j in range(m):
			if a[p[j] - 1] > a[p[j]]:
				(a[p[j] - 1], a[p[j]]) = (a[p[j]], a[p[j] - 1])
	l.sort()
	if a == l:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	z = list(map(int, input().split()))
	y = list(map(int, input().split()))
	n = 0
	while n < a:
		w = 0
		for i in range(a - 1):
			if z[i] > z[i + 1]:
				w = 1
				if i + 1 in y:
					(z[i], z[i + 1]) = (z[i + 1], z[i])
				else:
					print('NO')
					a = -1
					break
		if w == 0 or a == -1:
			break
		n += 1
	if a > 0:
		print('YES')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	if l == sorted(l):
		print('YES')
	elif l == sorted(l, reverse=True) and len(p) != n - 1:
		print('NO')
	elif l == sorted(l, reverse=True) and len(p) == n - 1 and (n not in p):
		print('YES')
	else:
		while l != sorted(l):
			flag = 0
			for i in range(n - 1):
				if l[i] > l[i + 1]:
					if i + 1 not in p:
						flag = 1
						break
					else:
						(l[i], l[i + 1]) = (l[i + 1], l[i])
			if flag == 1:
				print('NO')
				break
			if l == sorted(l):
				print('YES')


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(N, M) = [int(x) for x in input().split()]
		A = [int(x) for x in input().split()]
		P = set([int(x) for x in input().split()])
		A_sorted = []
		for (i, a) in enumerate(A):
			A_sorted.append([a, i])
		A_sorted.sort()
		f = True
		for (i, v) in enumerate(A_sorted):
			if i == v[1]:
				continue
			if i > v[1]:
				for j in range(v[1] + 1, i + 1):
					if j not in P:
						f = False
			else:
				for j in range(i + 1, v[1] + 1):
					if j not in P:
						f = False
		if f:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for _ in range(t):
	x = list(map(int, input().split()))
	a = list(map(int, input().split()))
	swap = list(map(int, input().split()))
	n = x[0]
	m = x[1]
	b = []
	for i in range(n):
		b.append(a[i])
	b.sort()
	breaking = 0
	fill = 0
	freq = {}
	for i in swap:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	for i in range(n):
		if a[i] != b[i]:
			p = a.index(b[i])
			for j in range(i, p):
				if j + 1 in freq:
					continue
				else:
					breaking = 1
					break
			if breaking == 1:
				break
			else:
				for j in range(p - i):
					if p - j - 1 >= 0 and p - j < n:
						(a[p - j], a[p - j - 1]) = (a[p - j - 1], a[p - j])
			a[i] = 100000 - i
		else:
			a[i] = 100000 - i
			continue
	if breaking == 1:
		print('NO')
	else:
		print('YES')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = [False] * n
	for i in list(map(int, input().split())):
		p[i - 1] = True
	while True:
		repeat = False
		for i in range(n):
			if p[i] and a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				repeat = True
		if not repeat:
			break
	print('YES') if all((a[i] <= a[i + 1] for i in range(n - 1))) else print('NO')


from sys import stdin

def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	u = [0] * n
	p = list(map(int, input().split()))
	for x in p:
		u[x - 1] = 1
	p = []
	for i in range(n):
		if u[i] == 0:
			p.append(i)
	pos = 0
	prevmx = -1
	curmx = -1
	curmn = 101
	for i in range(n):
		curmn = min(a[i], curmn)
		curmx = max(a[i], curmx)
		if i == p[pos]:
			if curmn < prevmx:
				return print('NO')
			prevmx = curmx
			curmx = -1
			curmn = 101
			pos += 1
	print('YES')
for i in range(int(input())):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	ans = True
	for _ in range(n):
		i = 0
		while i < n - 1:
			if a[i] > a[i + 1]:
				if i + 1 in p:
					x = a[i]
					a[i] = a[i + 1]
					a[i + 1] = x
				else:
					ans = False
					break
			i += 1
		if not ans:
			break
	if ans:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ara = list(map(int, input().strip().split()))
	p = list(map(int, input().strip().split()))
	for i in range(m):
		p[i] -= 1
	p.sort()
	ara2 = sorted(ara)
	ara2.sort()
	for j in range(n - 1):
		for i in range(n - 1):
			if ara[i] > ara[i + 1] and i in p:
				(ara[i], ara[i + 1]) = (ara[i + 1], ara[i])
	if ara == ara2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(len(p)):
		p[i] -= 1
	t = sorted(a)
	flag = True
	while flag:
		flag = False
		for i in p:
			if a[i + 1] < a[i]:
				flag = True
				break
		if flag:
			temp = a[i]
			a[i] = a[i + 1]
			a[i + 1] = temp
	realflag = True
	for i in range(n):
		if a[i] != t[i]:
			realflag = False
			break
	if realflag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	arr = []
	for i in a:
		arr.append(i)
	arr = sorted(arr)
	d = [0] * n
	for i in b:
		d[i - 1] = 1
	i = n - 1
	k = n - 1
	flag = 0
	while i >= 0:
		j = k
		while j >= 0:
			if a[j] == arr[i]:
				break
			j -= 1
		while j < k:
			if d[j] == 1:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
			else:
				flag = 1
				break
			j += 1
		if flag == 1:
			break
		k -= 1
		i -= 1
	if flag == 1:
		print('NO')
	elif arr == a:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	p = set((int(x) - 1 for x in input().split()))
	ans = None
	for i in range(len(a) - 1):
		min_val = min(a[i:])
		while min_val != a[i]:
			min_val_id = a[i:].index(min_val)
			if min_val_id + i - 1 in p:
				(a[min_val_id + i], a[min_val_id + i - 1]) = (a[min_val_id + i - 1], a[min_val_id + i])
			else:
				ans = 'NO'
				break
		if ans is not None:
			break
	if ans is None:
		ans = 'YES'
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	n = list(map(int, input().split()))
	m = list(map(int, input().split()))
	l = len(m)
	for k in range(l):
		for j in m:
			if n[j - 1] > n[j]:
				t = n[j - 1]
				n[j - 1] = n[j]
				n[j] = t
	if n == sorted(n):
		print('YES')
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, k, arr, b):
	b.sort()
	for i in range(n):
		for j in range(k):
			if arr[b[j] - 1] > arr[b[j]]:
				(arr[b[j]], arr[b[j] - 1]) = (arr[b[j] - 1], arr[b[j]])
	if arr == sorted(arr):
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	(n, k) = get_int()
	a = int_arr()
	b = int_arr()
	solve(n, k, a, b)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(lambda x: int(x) - 1, input().split()))
	ps = list(map(lambda x: int(x) - 1, input().split()))
	p = [False] * 100
	for pi in ps:
		p[pi] = True
	sorted_arr = [a for a in arr]
	sorted_arr.sort()
	possible = True
	for i in range(n):
		if arr[i] < sorted_arr[i]:
			j = i
			while j - 1 >= 0 and sorted_arr[j - 1] != arr[i] and p[j - 1]:
				j -= 1
			if j - 1 < 0 or sorted_arr[j - 1] != arr[i]:
				possible = False
				break
		elif arr[i] > sorted_arr[i]:
			j = i
			while j < n and sorted_arr[j] != arr[i] and p[j]:
				j += 1
			if j >= n or sorted_arr[j] != arr[i]:
				possible = False
				break
	if possible:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	(l1, l2) = ([], [])
	for i in l:
		l1.append(i)
		l2.append(i)
	l2.sort()
	p = list(map(int, input().split()))
	f = 0
	k = 0
	while f == 0:
		o = 0
		if l == l2:
			break
		for i in range(len(p)):
			if l[p[i] - 1] > l[p[i]]:
				(l[p[i] - 1], l[p[i]]) = (l[p[i]], l[p[i] - 1])
			else:
				o += 1
		if o == len(p):
			f += 1
			break
	if f == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	nlist = list(map(int, input().split()))
	plist = list(map(int, input().split()))
	tlist = nlist.copy()
	tlist.sort()
	check = []
	for j in range(100):
		check.append(-1)
	flag = 1
	for j in range(n):
		if check[nlist[j] - 1] == -1:
			pos = tlist.index(nlist[j])
			check[nlist[j] - 1] = pos
		else:
			pos = check[nlist[j] - 1] + 1
			check[nlist[j] - 1] += 1
		if pos < j:
			for k in range(pos, j):
				if k + 1 not in plist:
					flag = 0
					break
		elif pos > j:
			for k in range(j, pos):
				if k + 1 not in plist:
					flag = 0
					break
	if flag == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = [0] * n
	for i in input().split():
		p[int(i) - 1] = 1
	index = 0
	while index < n:
		left = index
		while index < n and p[index] == 1:
			index += 1
		index += 1
		a = a[:left] + sorted(a[left:index]) + a[index:]
	if sorted(a) != a:
		print('NO')
	else:
		print('YES')


for eps in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	check = [False] * n
	for elem in b:
		check[elem - 1] = True
	b = sorted(a)
	i = 0
	k = 1
	while i < len(a) - 1 and k != 0:
		k = 0
		i = i + 1
		for j in range(len(a) - i):
			if a[j] > a[j + 1] and check[j]:
				k = k + 1
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if a == b:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input().strip())):
	(n, m) = list(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	l = list(map(int, input().strip().split()))
	se = set()
	for x in l:
		se.add(x - 1)
	val = True
	for i in range(n):
		for j in range(n - 1):
			if arr[j] > arr[j + 1]:
				if j not in se:
					val = False
					break
				else:
					te = arr[j]
					arr[j] = arr[j + 1]
					arr[j + 1] = te
		if not val:
			break
	if val:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l2 = sorted(list(map(int, input().split())))
	for i in range(a):
		for j in l2:
			if l[j - 1] > l[j]:
				(l[j - 1], l[j]) = (l[j], l[j - 1])
	if l != sorted(l):
		print('NO')
	else:
		print('YES')


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for tt in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	a = list(map(int, input().split()))
	d = {i - 1: 1 for i in a}
	lsort = sorted(l)
	flag = True
	check = set()
	for i in range(n):
		if l[i] != lsort[i] or i in check:
			for j in range(n):
				if l[i] == lsort[j] and j not in check:
					ind = j
					check.add(j)
					break
			if ind > i:
				for k in range(i, ind):
					if k not in d:
						flag = False
			else:
				for k in range(ind, i):
					if k not in d:
						flag = False
		else:
			check.add(i)
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = 0
	for i in range(n):
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				if i + 1 not in p:
					c = 1
					print('NO')
					break
				else:
					temp = a[i]
					a[i] = a[i + 1]
					a[i + 1] = temp
		if c == 1:
			break
	if c == 0:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p = set(p)
	while 1:
		f = 0
		for i in range(n - 1):
			if a[i] > a[i + 1] and i + 1 in p:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				f = 1
		if not f:
			break
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


tc = int(input())
for i in range(tc):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * (n + 2)
	c = list(map(int, input().split()))
	for i in c:
		x = i - 1
		b[x] = 1
	f = 0
	for i in range(n - 1, -1, -1):
		j = i
		while j + 1 < n:
			if a[j] > a[j + 1] and b[j] == 0:
				f = 1
				break
			elif a[j] > a[j + 1] and b[j] == 1:
				temp = a[j]
				a[j] = a[j + 1]
				a[j + 1] = temp
				j += 1
			else:
				break
		if f == 1:
			break
	if f == 0:
		print('YES')
	else:
		print('NO')


T = int(input())
while T > 0:
	T -= 1
	(n, m) = map(int, input().split(' '))
	a = [int(i) - 1 for i in input().split(' ')]
	r = [int(i) - 1 for i in input().split(' ')]
	p = [0 for i in range(n)]
	for i in r:
		p[i] = 1
	while True:
		ok = False
		for i in range(n - 1):
			if p[i] and a[i] > a[i + 1]:
				ok = True
				(a[i], a[i + 1]) = (a[i + 1], a[i])
		if not ok:
			break
	ok = True
	for i in range(n - 1):
		ok &= a[i] <= a[i + 1]
	if ok:
		print('YES')
	else:
		print('NO')


t = int(input())
for T in range(t):
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	pos = list(map(int, input().split()))
	for z in range(len(pos)):
		pos[z] -= 1
	pos.sort()
	for x in range(len(arr)):
		for i in pos:
			if arr[i] > arr[i + 1]:
				(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
	ans = 'YES'
	for x in range(len(arr) - 1):
		if arr[x] > arr[x + 1]:
			ans = 'NO'
	print(ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = set(map(int, input().split()))
	current = []
	out = []
	for (i, x) in enumerate(a):
		if i + 1 in p:
			current += [x]
		elif i in p:
			current += [x]
			out += sorted(current)
			current = []
		else:
			out += sorted(current) + [x]
			current = []
	out += sorted(current)
	res = out == sorted(a)
	print(('NO', 'YES')[res])


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	l = a[:]
	l.sort()
	p.sort()
	flag = 0
	start = p[0]
	arr = []
	for j in range(1, len(p) + 1):
		if j == len(p) or p[j] - p[j - 1] != 1:
			arr.append([start - 1, p[j - 1]])
			start = p[j] if j != len(p) else 0
		else:
			continue
	for j in arr:
		val = a[j[0]:j[1] + 1]
		val.sort()
		if val == l[j[0]:j[1] + 1]:
			continue
		else:
			flag = 1
			break
	for j in range(1, n + 1):
		if j not in p and j - 1 not in p:
			if a[j - 1] != l[j - 1]:
				flag = 1
				break
	if flag == 0:
		print('YES')
	else:
		print('NO')


testCases = int(input())
for i1 in range(testCases):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	for i2 in range(m, 0, -1):
		for i3 in p[0:i2]:
			if a[i3] < a[i3 - 1]:
				c = a[i3]
				a[i3] = a[i3 - 1]
				a[i3 - 1] = c
	b = sorted(a)
	result = 'YES'
	for i2 in range(n):
		if b[i2] != a[i2]:
			result = 'NO'
			break
	print(result)


def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	a.append(999)
	a.append(999)
	a.append(999)
	a.append(999)
	asort = a.copy()
	asort.sort()
	D = [[0] * 110 for _ in range(0, 110)]
	for x in p:
		D[x - 1][x] = True
	seg_unsort = []
	seg_sort = []
	connect = False
	for i in range(0, n + 1):
		if D[i][i + 1] == True:
			if connect == True:
				seg_unsort.append(a[i + 1])
				seg_sort.append(asort[i + 1])
			else:
				connect = True
				seg_unsort.append(a[i])
				seg_unsort.append(a[i + 1])
				seg_sort.append(asort[i])
				seg_sort.append(asort[i + 1])
		elif connect == True:
			connect = False
			seg_unsort.sort()
			seg_sort.sort()
			if seg_unsort != seg_sort:
				print('NO')
				return
			seg_unsort = []
			seg_sort = []
		elif a[i] != asort[i]:
			print('NO')
			return
	print('YES')
T = int(input())
while T > 0:
	T -= 1
	solve()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	s = set(p)
	poss = True
	for i in range(1, n):
		for j in range(i, 0, -1):
			if a[j] < a[j - 1]:
				if j not in s:
					poss = False
					break
				(a[j], a[j - 1]) = (a[j - 1], a[j])
			else:
				break
	if poss:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	c = [0] * 101
	(k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in b:
		c[j] = 1
	f = True
	for j in range(k - 1):
		for h in range(k - j - 1):
			if a[h] > a[h + 1]:
				if c[h + 1] == 0:
					f = False
					break
				else:
					(a[h], a[h + 1]) = (a[h + 1], a[h])
	if f:
		print('YES')
	else:
		print('NO')


n = int(input())
l2 = []
for x in range(n):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(b):
		p[i] = p[i] - 1
	l1 = sorted(l)
	p1 = []
	p.sort()
	for j in range(b):
		k = j
		while j + 1 <= b - 1 and p[j + 1] == p[j] + 1:
			j = j + 1
		p1 = l[p[k]:p[j] + 2]
		l[p[k]:p[j] + 2] = sorted(p1)
	if l == l1:
		l2.append('YES')
	else:
		l2.append('NO')
for x in l2:
	print(x)


t = int(input())
a = []
for i in range(t):
	(e, f) = input().split()
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	a.append([b, c])
for i in a:
	k = i[0]
	d = i[1]
	l = 0
	while l != 1:
		n = 0
		for j in range(1, len(k)):
			if k[j] < k[j - 1]:
				n = 1
				if j not in d:
					l = 1
					break
				else:
					t = k[j]
					k[j] = k[j - 1]
					k[j - 1] = t
		if l == 1:
			break
		if n == 0:
			break
	if l == 1:
		print('NO')
	if n == 0:
		print('YES')


import math
t = int(input())
for test in range(t):
	[n, m] = [int(i) for i in input().split(' ')]
	seq = [int(i) for i in input().split(' ')]
	srt = [int(i) for i in input().split(' ')]
	srt.sort()
	bl = [False for _ in range(n)]
	for c in srt:
		bl[c - 1] = True
	cp = seq.copy()
	cp.sort()
	doable = True
	for i in range(len(cp)):
		for j in range(len(seq)):
			if cp[i] == seq[j]:
				seq[j] = -1
				for k in range(min(i, j), max(i, j)):
					if not bl[k]:
						doable = False
						break
				break
	if doable:
		print('YES')
	else:
		print('NO')


def solution(n, m, a: list, p: list):
	p = [pi - 1 for pi in p]
	perm = False
	while True:
		for pi in p:
			if a[pi] > a[pi + 1]:
				a.insert(pi, a.pop(pi + 1))
				perm = True
		if not perm:
			break
		perm = False
	if a == sorted(a):
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	solution(n, m, a, p)


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a1 = sorted(a)
	p = list(map(int, input().split()))
	flag = 0
	while a != a1:
		for j in range(n - 1):
			if a[j] > a[j + 1]:
				if j + 1 in p:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
				else:
					flag = 1
					break
		if flag == 1:
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	li = list(map(int, input().split()))
	li1 = sorted(li)
	p = list(map(int, input().split()))
	k = 1
	while k <= 100:
		for i in p:
			for j in range(100):
				try:
					if li[i - 1] > li[i]:
						(li[i - 1], li[i]) = (li[i], li[i - 1])
					else:
						break
				except:
					break
		k += 1
	if li == li1:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort()
	d = {}
	for i in b:
		d[i] = 1
	c = []
	e = []
	if n == 1:
		print('YES')
	else:
		for i in range(n):
			c.append(a[i])
			if i + 1 not in d:
				c.sort()
				e += c[:]
				c = []
		c.sort()
		e += c
		a.sort()
		for i in range(n):
			if a[i] != e[i]:
				print('NO')
				break
		else:
			print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	lst = []
	for i in p:
		lst.append([i - 1, i])
	x = a[:]
	x.sort()
	for i in range(n - 1):
		for j in range(n - i - 1):
			if a[j] > a[j + 1] and [j, j + 1] in lst:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if x == a:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for j in range(int(input())):
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	ans = 'YES'
	for g in range(n):
		for go in range(n - 1):
			if a[go] > a[go + 1] and go + 1 not in p:
				ans = 'NO'
			elif a[go] > a[go + 1]:
				temp = a[go + 1]
				a[go + 1] = a[go]
				a[go] = temp
	print(ans)


I = lambda : [*map(int, input().split())]
for _ in range(int(input())):
	I()
	A = I()
	P = I()
	while True:
		swapped = False
		for p in P:
			if A[p - 1] > A[p]:
				(A[p - 1], A[p]) = (A[p], A[p - 1])
				swapped = True
		if not swapped:
			break
	print('YES' if A == sorted(A) else 'NO')


import sys

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

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

def oint():
	return int(input())
t = oint()
for _ in range(t):
	(n, m) = rint()
	a = list(rint())
	a_sorted = a[:]
	a_sorted.sort()
	p = list(rint())
	for i in range(m):
		p[i] -= 1
	p.sort()
	s = p[0]
	e = p[0] + 1
	ans = []
	for i in range(1, m):
		if p[i] - e > 0:
			ans = sorted(a[s:min(e + 1, n)])
			for j in range(s, min(e + 1, n)):
				a[j] = ans[j - s]
			s = p[i]
			e = p[i] + 1
		else:
			e = p[i] + 1
	ans = sorted(a[s:min(e + 1, n)])
	for j in range(s, min(e + 1, n)):
		a[j] = ans[j - s]
	if a_sorted == a:
		print('YES')
	else:
		print('NO')


t = int(input())
for tc in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	result = 'YES'
	targetIdx = []
	i = 0
	while i < n - 1:
		if a[i] > a[i + 1]:
			if i + 1 in p:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				if i != 0:
					i -= 1
				else:
					i += 1
			else:
				result = 'NO'
				break
		else:
			i += 1
	print(result)


T = int(input().strip())
debug = False
for t in range(T):
	(m, n) = map(int, input().split())
	A = list(map(int, input().split()))
	P = list(map(int, input().split()))
	dP = {}
	for p in P:
		dP[p] = 1
	moves = 1
	status = 'YES'
	while moves > 0:
		moves = 0
		for i in range(m - 1):
			if A[i] > A[i + 1]:
				if i + 1 in dP:
					tmp = A[i]
					A[i] = A[i + 1]
					A[i + 1] = tmp
					moves += 1
				else:
					status = 'NO'
					moves = 0
					break
	print(status)


import sys
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 998244353
for _ in range(int(ri())):
	(n, m) = Ri()
	a = Ri()
	p = Ri()
	p = [i - 1 for i in p]
	flag = True
	dic = set(p)
	for i in range(n):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1]:
				if j in dic:
					(a[j + 1], a[j]) = (a[j], a[j + 1])
				else:
					flag = False
					break
		if not flag:
			break
	if flag:
		YES()
	else:
		NO()


t = int(input())
for tt in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	d = {}
	for i in p:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	flag = True
	for i in range(len(arr) - 1):
		for j in range(len(arr) - i - 1):
			if arr[j] > arr[j + 1]:
				if j + 1 not in d:
					flag = False
					break
				else:
					temp = arr[j]
					arr[j] = arr[j + 1]
					arr[j + 1] = temp
		if flag == False:
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	nums = list(map(int, input().split()))
	p = list(map(int, input().split()))
	f = 0
	dup = nums.copy()
	dup.sort()
	for i in range(m):
		for j in p:
			if nums[j] < nums[j - 1]:
				(nums[j], nums[j - 1]) = (nums[j - 1], nums[j])
	print('YES' if dup == nums else 'NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	A = list(map(int, input().split(' ')))
	B = list(map(int, input().split(' ')))
	mark = {}
	if len(B) == len(A):
		print('YES')
	else:
		for i in B:
			mark[i - 1] = 1
		C = A.copy()
		C.sort()
		j = 0
		flag = 0
		while j < len(A):
			if C[j] == A[j]:
				j += 1
				continue
			else:
				for i in range(j, len(A)):
					if A[i] == C[j]:
						if mark.get(i - 1, 0) == 1:
							(A[i - 1], A[i]) = (A[i], A[i - 1])
							j -= 1
							break
						else:
							flag = 1
							break
			j += 1
			if flag == 1:
				break
		print('YES') if flag == 0 else print('NO')


t = int(input())
while t:
	(n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	p = [int(i) - 1 for i in input().split()]
	flag = True
	while a != sorted(a) and flag:
		for i in range(0, len(a) - 1):
			if a[i] > a[i + 1]:
				if i in p:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
				else:
					flag = False
					break
	if flag:
		print('YES')
	else:
		print('NO')
	t -= 1


n = int(input())
for i in range(n):
	(n, m) = [int(k) for k in input().split()]
	a = [int(k) for k in input().split()]
	p = [int(k) - 1 for k in input().split()]
	sor = sorted(a)
	can = None
	ori = list(a)
	ant = list(a)
	while a != sor:
		for j in range(len(p)):
			if a[p[j]] > a[p[j] + 1]:
				aux = a[p[j]]
				a[p[j]] = a[p[j] + 1]
				a[p[j] + 1] = aux
			if a == sor:
				break
		if a == sor:
			can = True
			break
		if a == ori:
			can = False
			break
		if ant == a:
			can = False
			break
		else:
			ant = list(a)
	if a == sor:
		can = True
	if can:
		print('YES')
	else:
		print('NO')


a = int(input())
for x in range(a):
	(b, c) = map(int, input().split())
	d = list(map(int, input().split()))
	e = list(map(int, input().split()))
	f = d.copy()
	f.sort()
	j = True
	while True:
		j = False
		for y in e:
			if d[y - 1] > d[y]:
				(d[y - 1], d[y]) = (d[y], d[y - 1])
				j = True
		if j == False:
			break
	if d == f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	if a == sorted(a):
		print('YES')
	else:
		f = 0
		for i in range(n):
			for j in range(m):
				if a[p[j] - 1] < a[p[j]]:
					continue
				else:
					temp = a[p[j] - 1]
					a[p[j] - 1] = a[p[j]]
					a[p[j]] = temp
		if a == sorted(a):
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(m, n) = input().split()
	m = int(m)
	n = int(n)
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	repeat = True
	while repeat:
		repeat = False
		for pmem in p:
			if a[pmem - 1] > a[pmem]:
				repeat = True
				(a[pmem - 1], a[pmem]) = (a[pmem], a[pmem - 1])
	ans = 'YES'
	for index in range(len(a) - 1):
		if a[index] > a[index + 1]:
			ans = 'NO'
			break
	print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('../output.txt', 'w')
except:
	pass
for _ in range(L()[0]):
	(n, m) = L()
	A = L()
	p = L()
	d = {}
	for ele in p:
		d[ele - 1] = 1
	changed = 1
	while changed:
		changed = 0
		for i in range(n - 1):
			if A[i] > A[i + 1] and d.get(i, 0):
				changed = 1
				(A[i], A[i + 1]) = (A[i + 1], A[i])
	if A == sorted(A):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	s = set(p)
	l = sorted(a)
	f1 = True
	for j in range(n):
		f = True
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				f = False
				if i + 1 in s:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
		if f:
			print('YES')
			f1 = False
			break
	if f1:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	p = [int(q) for q in input().split()]
	if a == sorted(a):
		print('YES')
	else:
		for i in range(n):
			for j in range(0, n - i - 1):
				if a[j] > a[j + 1]:
					if j + 1 in p:
						(a[j], a[j + 1]) = (a[j + 1], a[j])
		if a == sorted(a):
			print('YES')
		else:
			print('NO')


def dfs(s, p):
	visited.add(s)
	if s == p:
		return True
	for i in d[s]:
		if i not in visited:
			return dfs(i, p)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	k = list(map(int, input().split()))
	ans = sorted(l)
	j = 0
	while j < len(l):
		for i in k:
			if l[i - 1] > l[i]:
				(l[i - 1], l[i]) = (l[i], l[i - 1])
		j += 1
	print('YES' if l == ans else 'NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	flag = 1
	if a == sorted(a):
		print('YES')
		continue
	while a != sorted(a):
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				if i + 1 in p:
					temp = a[i]
					a[i] = a[i + 1]
					a[i + 1] = temp
				else:
					flag = 0
					break
			if i == n - 2:
				i = 0
		if flag == 1:
			if a == sorted(a):
				print('YES')
				break
			else:
				continue
		else:
			print('NO')
			break


def f(x):
	return int(x) - 1
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(f, input().split()))
	p.sort()
	flag = False
	s = []
	for i in range(n - 1):
		if i in p:
			if flag == False:
				s.append(i)
				flag = True
		elif flag:
			if i - 1 in p:
				s.append(i)
				flag = False
		else:
			s.append(i)
			s.append(i)
			flag = False
	if flag == True:
		s.append(n - 1)
	else:
		s.append(n - 1)
		s.append(n - 1)
	fi = l[:]
	l.sort()
	flag = False
	for i in range(0, len(s), 2):
		temp = fi[s[i]:s[i + 1] + 1]
		temp.sort()
		temp2 = l[s[i]:s[i + 1] + 1]
		flag = False
		for j in range(s[i + 1] - s[i] + 1):
			if temp[j] != temp2[j]:
				flag = True
				break
		if flag == True:
			break
	if flag == True:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	pos = []
	pos.append({p[0] - 1})
	if p[0] != n:
		pos[-1].add(p[0])
	for i in range(1, m):
		if p[i] - p[i - 1] == 1:
			pos[-1].add(p[i] - 1)
		else:
			pos.append({p[i] - 1})
		if p[i] != n:
			pos[-1].add(p[i])
	for s in pos:
		arr_sort = []
		for i in s:
			arr_sort.append(arr[i])
		arr_sort.sort()
		for i in range(len(list(s))):
			arr[list(s)[i]] = arr_sort[i]
	if arr == sorted(arr):
		print('YES')
	else:
		print('NO')


from sys import stdin

def inp():
	return next((ss.rstrip() for ss in stdin))

def itg():
	return int(inp())

def mpint():
	return map(int, inp().split())

def main():
	(n, m) = mpint()
	arr = list(mpint())
	st = set((int(i) - 1 for i in inp().split()))
	sorted_arr = list(sorted(arr))
	r_sorted = list(reversed(sorted_arr))
	for i in range(n):
		a = arr[i]
		idx1 = sorted_arr.index(a)
		idx2 = n - 1 - r_sorted.index(a)
		if idx1 <= i <= idx2:
			continue
		tmp = i
		if tmp > idx1:
			(idx1, tmp) = (tmp, idx1)
		for j in range(tmp, idx1):
			if j not in st:
				break
		else:
			continue
		tmp = i
		if tmp > idx2:
			(idx2, tmp) = (tmp, idx2)
		for j in range(tmp, idx2):
			if j not in st:
				return 'NO'
	return 'YES'
for case in range(itg()):
	print(main())


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = [int(item) for item in input().split()]
	a = [int(item) for item in input().split()]
	p = [int(item) for item in input().split()]
	pset = set(p)
	group = []
	group.append(a[0])
	ret = []
	for i in range(1, n):
		if i in pset:
			group.append(a[i])
		else:
			ret += sorted(group)
			group = [a[i]]
	ret += sorted(group)
	if ret == sorted(a):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(j) for j in input().split()]
	nums = [int(j) for j in input().split()]
	points = [int(j) for j in input().split()]
	status = n * [0]
	for j in range(m):
		status[points[j] - 1] = 1
	for j in range(n):
		for k in range(n - 1):
			if nums[k] > nums[k + 1] and status[k] == 1:
				(nums[k], nums[k + 1]) = (nums[k + 1], nums[k])
	if nums == sorted(nums):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	perm = set(map(int, input().split()))
	ans = 'YES'
	for i in range(n):
		mnpos = i
		for j in range(i, n):
			if arr[j] < arr[mnpos]:
				mnpos = j
		for j in range(mnpos, i, -1):
			if j not in perm:
				ans = 'NO'
				break
			(arr[j], arr[j - 1]) = (arr[j - 1], arr[j])
		if ans == 'NO':
			break
	print(ans)


def halt():
	while True:
		pass
testcase = int(input())
for t in range(1, testcase + 1):
	(size_n, size_p) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	p = list(map(int, input().split(' ')))
	flag = 1
	count = 0
	sorted_arr = sorted(arr)
	i = 0
	index = 0
	while True:
		if sorted_arr == arr:
			break
		i = index % size_n
		if i < size_n - 1:
			if arr[i] > arr[i + 1]:
				if i + 1 in p:
					(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
				else:
					flag = 0
					break
		index += 1
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	forward = {}
	backward = {}
	for i in p:
		forward[i] = i + 1
		backward[i + 1] = i
	for i in range(n):
		a[i] = (a[i], i + 1)
	a.sort()
	possible = True
	for i in range(1, n + 1):
		p = a[i - 1][1]
		if p != i:
			if p < i:
				t = forward
			else:
				t = backward
			while True:
				if p in t:
					p = t[p]
					if p == i:
						break
				else:
					possible = False
					break
	print('YES' if possible else 'NO')


import math
import collections
import functools
import sys
import os

def solve():
	(n, _) = map(int, input().split())
	table = list(map(int, input().split()))
	per = list(map(int, input().split()))
	dis = [i for i in range(n)]
	per.sort(reverse=True)
	for idx in per:
		dis[idx - 1] = dis[idx]
	for i in range(n):
		temp = table[i:dis[i] + 1]
		temp.sort()
		table[i:dis[i] + 1] = temp
	pre = -1
	for i in table:
		if pre > i:
			print('NO')
			return
		pre = i
	print('YES')
	return

def main():
	T = 1
	T = int(input())
	while T:
		solve()
		T -= 1
main()


t = int(input())
for iii in range(t):
	(n, m) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a2 = sorted(a1)
	p = list(map(int, input().split()))
	new1 = {a1[i]: i for i in range(n)}
	new2 = {a2[i]: i for i in range(n)}
	set1 = set()
	for x in new1:
		one = min(new1[x], new2[x])
		two = max(new1[x], new2[x])
		set1 |= {i + 1 for i in range(one, two)}
	set2 = set(p)
	if set1 <= set2:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	can = [0] * 105
	for i in p:
		can[i - 1] = 1
	flag = 1
	for i in range(n - 1, -1, -1):
		for j in range(0, i):
			if a[j] > a[j + 1]:
				if can[j]:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
				else:
					flag = 0
					break
		if flag == 0:
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for i in range(n):
		for k in p:
			if a[k - 1] > a[k]:
				temp = a[k - 1]
				a[k - 1] = a[k]
				a[k] = temp
	x = 1
	for v in range(n - 1):
		if a[v] > a[v + 1]:
			x = 0
			break
	print(['NO', 'YES'][x])


t = int(input())
for ti in range(t):
	(n, m) = (int(i) for i in input().split(' '))
	ans = 0
	li = [int(i) for i in input().split(' ')]
	sw = [int(i) - 1 for i in input().split(' ')]
	sw.sort()
	p = mx = 0
	swp = 0
	cur = sw[0]
	while p < n:
		dst = 1
		if p == cur:
			dst += 1
			bf = 0
			for idx in range(swp + 1, m):
				i = sw[idx]
				if idx == 0:
					dst += 1
					cur = i
				elif i == cur + 1:
					dst += 1
					cur = i
					swp = idx
				else:
					cur = i
					swp = idx
					bf = 1
					break
			if bf == 0:
				cur = 9999999
		cmx = li[p]
		cmn = li[p]
		while dst > 0:
			cmn = min(li[p], cmn)
			cmx = max(li[p], cmx)
			dst -= 1
			p += 1
		if cmn >= mx:
			mx = cmx
		else:
			ans = 1
			print('NO')
			break
	if ans == 0:
		print('YES')


t = int(input())
for _ in range(t):
	input()
	a = [int(x) for x in input().split()]
	p = [int(x) - 1 for x in input().split()]
	for y in range(101):
		for pi in p:
			if a[pi + 1] < a[pi]:
				(a[pi + 1], a[pi]) = (a[pi], a[pi + 1])
	newA = list(sorted(a))
	if a != newA:
		print('NO')
	else:
		print('YES')


q = int(input())
while q:
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	b = 1
	for i in range(n - 1):
		for j in range(n - i - 1):
			if a[j] > a[j + 1]:
				if j + 1 not in p:
					b = 0
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	if b:
		print('YES')
	else:
		print('NO')
	q -= 1


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	p = [int(x) - 1 for x in input().split()]
	p.sort()
	flag = 0
	for end in range(n - 1, 0, -1):
		for i in range(0, end):
			if a[i] > a[i + 1]:
				if i in p:
					temp = a[i]
					a[i] = a[i + 1]
					a[i + 1] = temp
				else:
					flag = 1
					print('NO')
					break
		if flag:
			break
	else:
		print('YES')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	k = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = []
	for i in range(len(k)):
		for j in range(0, len(k) - 1 - i):
			if k[j] > k[j + 1]:
				(k[j], k[j + 1]) = (k[j + 1], k[j])
				l3 += [j + 1]
	if set(l3).issubset(set(l2)):
		print('YES')
	else:
		print('NO')


for test in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	flag1 = True
	for i in range(n):
		flag = True
		for j in range(n - 1):
			if a[j] > a[j + 1]:
				flag = False
				k = j + 1
				if k in p:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
		if flag == True:
			print('YES')
			flag1 = False
			break
	if flag1 == True:
		print('NO')


def weirdsort(a, b):
	for i in range(len(a) - 1):
		if i + 1 in b:
			continue
		s1 = a[0:i + 1]
		s2 = a[i + 1:]
		if max(s1) > min(s2):
			return 'NO'
	return 'YES'
t = int(input())
for case in range(t):
	nm = [int(x) for x in input().split(' ')]
	n = nm[0]
	m = nm[1]
	a = [int(x) for x in input().split(' ')]
	p = [int(x) for x in input().split(' ')]
	print(weirdsort(a, p))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for j in range(n):
		for k in p:
			if a[k - 1] > a[k]:
				(a[k - 1], a[k]) = (a[k], a[k - 1])
	ans = 'YES'
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			ans = 'NO'
			break
	print(ans)


T = int(input())
for case in range(T):
	(n, m) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	p = list(map(int, input().strip().split()))
	st = set()
	for x in p:
		x -= 1
		if x not in st:
			st.add(x)
	ok = True
	for i in range(n - 1):
		for j in range(n - 1 - i):
			if a[j] > a[j + 1]:
				if j not in st:
					ok = False
					break
				else:
					temp = a[j]
					a[j] = a[j + 1]
					a[j + 1] = temp
		if not ok:
			break
	if ok:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	a = input()
	arr = list(map(int, input().split()))
	p = list(map(int, input().split()))
	while True:
		n = 0
		for i in p:
			i -= 1
			if arr[i] > arr[i + 1]:
				r = arr[i + 1]
				arr[i + 1] = arr[i]
				arr[i] = r
				n += 1
		if n == 0:
			break
	if arr == sorted(arr):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	swa = list(map(int, input().split()))
	swa.sort()
	np = 0
	for i in range(n):
		for j in swa:
			if arr[j - 1] > arr[j]:
				(arr[j - 1], arr[j]) = (arr[j], arr[j - 1])
	if arr != sorted(arr):
		print('NO')
	else:
		print('YES')


def findpositions(a, n):
	for i in range(0, n - 1):
		if a[i] > a[i + 1]:
			return i
	if n == 2:
		if a[0] > a[1]:
			return 0
	return -1
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	valid = list(map(int, input().split()))
	valid = [i - 1 for i in valid]
	sol = 0
	k = 0
	while 1:
		k = findpositions(a, n)
		if k == -1:
			break
		if k not in valid:
			sol = 1
			break
		(a[k], a[k + 1]) = (a[k + 1], a[k])
	if sol:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	actual = list()
	for i in range(n - 1):
		for j in range(n - i - 1):
			if a[j] > a[j + 1]:
				actual.append(j + 1)
				temp = a[j]
				a[j] = a[j + 1]
				a[j + 1] = temp
	for each in actual:
		if each in p:
			pass
		else:
			print('NO')
			break
	else:
		print('YES')


def find_last_mx(arr, mx):
	i = len(arr) - 1
	while arr[i] != mx:
		i -= 1
	return i

def solve(arr, arrSorted, swaps, n):
	while n:
		mx = arrSorted[n]
		pos = find_last_mx(arr[:n + 1], mx)
		for x in range(pos, n):
			if x not in swaps:
				return 'NO'
			else:
				(arr[x], arr[x + 1]) = (arr[x + 1], arr[x])
		n -= 1
	return 'YES'
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	swaps = set([int(x) - 1 for x in input().split()])
	n -= 1
	arrSorted = sorted(arr)
	print(solve(arr, arrSorted, swaps, n))


from sys import stdin
t = int(stdin.readline())
while t:
	t -= 1
	(n, m) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	p = list(map(int, stdin.readline().split()))
	ans = 'YES'
	while True:
		if list(sorted(a)) != a[:]:
			for i in range(n - 1):
				if a[i] > a[i + 1]:
					if i + 1 not in p:
						ans = 'NO'
						break
					else:
						(a[i], a[i + 1]) = (a[i + 1], a[i])
		else:
			break
		if ans == 'NO':
			break
	print(ans)


import bisect
list_ans = []
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	list1 = list(map(int, input().split()))
	set1 = set(map(int, input().split()))
	list2 = sorted(list1)
	set2 = set()
	for x in range(n):
		if list1[x] < list2[x]:
			m = bisect.bisect_right(list2, list1[x])
			set2.update((i for i in range(m, x + 1)))
		elif list1[x] > list2[x]:
			m = bisect.bisect_left(list2, list1[x])
			set2.update((i for i in range(x + 1, m + 1)))
	if set2.issubset(set1):
		list_ans.append('YES')
	else:
		list_ans.append('NO')
print(*list_ans, sep='\n')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	la = list(map(int, input().split()))
	lm = list(map(int, input().split()))
	for i in range(a):
		for j in lm:
			if la[j - 1] > la[j]:
				(la[j - 1], la[j]) = (la[j], la[j - 1])
	if sorted(la) == la:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = [int(k) for k in input().split()]
	pos = [int(k) for k in input().split()]
	freq = [0] * 100
	for j in range(m):
		freq[pos[j] - 1] += 1
	if m == n - 1:
		print('YES')
	else:
		arr1 = arr[:]
		arr1.sort()
		counter = 0
		for i in range(n):
			ele = arr[i]
			index = arr1.index(ele)
			arr1[index] = -1
			if index == i:
				continue
			else:
				for k in range(i, index):
					if freq[k] == 1:
						continue
					else:
						counter = 1
						break
				if counter == 1:
					break
		if counter == 1:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = [*map(int, input().split())]
	p = sorted([*map(int, input().split())])
	for _ in range(n):
		for i in p:
			(l[i - 1], l[i]) = sorted(l[i - 1:i + 1])
	print(['NO', 'YES'][l == sorted(l)])


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	(n, m) = mi()
	a = list(mi())
	p = list(mi())
	p.sort()
	np = False
	for i in range(n):
		for j in range(n - 1):
			if a[j] > a[j + 1]:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
				if j + 1 not in p:
					np = True
					break
		if np:
			break
	if np:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	l1 = [int(j) for j in input().split()][:a]
	l2 = [int(j) for j in input().split()][:b]
	h = -1
	for j in range(0, a):
		y = -1
		for k in range(0, a - 1):
			if l1[k] > l1[k + 1]:
				if k + 1 not in l2:
					print('NO')
					y = 1
					h = 1
					break
				t = l1[k]
				l1[k] = l1[k + 1]
				l1[k + 1] = t
		if y == 1:
			break
	if h == -1:
		print('YES')


def seemsDfs(a, p):
	count = 1
	while count > 0:
		count = 0
		for x in p:
			if a[x - 1] > a[x]:
				a = swap(a, x - 1, x)
				count += 1
	return a

def swap(arr, p1, p2):
	temp = arr[p1]
	arr[p1] = arr[p2]
	arr[p2] = temp
	return arr
t = int(input())
for l in range(t):
	(m, n) = map(int, input().split())
	a = [int(x) for x in input().split()[:m]]
	p = [int(x) for x in input().split()[:n]]
	result = seemsDfs(a, p)
	for i in range(len(result) - 1):
		if result[i] > result[i + 1]:
			print('NO')
			break
		if i == len(result) - 2:
			print('YES')


t = int(input())
for t_case in range(t):
	(n, m) = map(int, input().split())
	N = list(map(int, input().split()))
	M = list(map(int, input().split()))
	D = set()
	L2 = [False for i in range(n)]
	L1 = L = [False for i1 in range(n)]
	L = [False for i2 in range(n)]
	L4 = [False for i3 in range(n)]
	for x in M:
		L2[x] = True
		L1[x - 1] = True
		L4[x] = True
		L4[x - 1] = True
	for h in range(n):
		if L1[h] == True and L2[h] == True:
			L[h] = True
	qw = 'YES'
	for j in range(n):
		if L4[j] == False:
			if j == 0:
				if N[j] > min(N[j + 1:]):
					qw = 'NO'
					break
			elif j == n - 1:
				if max(N[:j]) > N[j]:
					qw = 'NO'
					break
			if j != 0 and j != n - 1:
				if min(N[:j]) > N[j] or N[j] > max(N[j + 1:]):
					qw = 'NO'
					break
	if qw == 'YES':
		for y in range(n):
			if L1[y] == True and L[y] == False and (y != 0):
				if min(N[y:]) < max(N[:y]):
					qw = 'NO'
					break
	if qw == 'YES':
		for y1 in range(n):
			if L2[y1] == True and L[y1] == False and (y1 != n - 1):
				if min(N[y1 + 1:]) < max(N[:y1 + 1]):
					qw = 'NO'
					break
	print(qw)


t = int(input())
for _ in range(t):
	ans = []
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	for q in range(n):
		for i in sorted(p):
			if a[i - 1] > a[i]:
				(a[i - 1], a[i]) = (a[i], a[i - 1])
	ans.append('YES' if a == sorted(a) else 'NO')
	print(*ans)


t = int(input())

def help(arr, points, newArr):
	hash = [*arr]
	for (i, k) in enumerate(arr):
		if i + 1 != len(arr):
			for l in points:
				if i == l and arr[i] > arr[i + 1]:
					s = arr[i + 1]
					arr[i + 1] = arr[i]
					arr[i] = s
	if arr == hash:
		return
	elif not arr == newArr:
		help(arr, points, newArr)

def find(arr, points):
	for (i, l) in enumerate(points):
		points[i] = l - 1
	newArr = sorted(arr)
	if arr == newArr:
		print('YES')
	else:
		help(arr, points, newArr)
		if arr != newArr:
			print('NO')
		else:
			print('YES')
for i in range(t):
	arr = list()
	points = list()
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	points = list(map(int, input().split()))
	find(arr, points)


def part_sort(arr, start, end):
	for i in range(start, end + 2):
		count = 1
		for j in range(start, end + 2 - count):
			if arr[j] > arr[j + 1]:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
		count += 1

def sol():
	T = int(input())
	for i in range(T):
		(m, n) = map(int, input().split(' '))
		arr = list(map(int, input().split(' ')))
		p = list(map(int, input().split(' ')))
		for i in range(len(p)):
			p[i] -= 1
		p.sort()
		sort_range = []
		prev = p[0]
		nxt = p[0]
		for i in range(1, len(p)):
			if p[i] == nxt + 1:
				nxt += 1
				continue
			sort_range.append((prev, nxt))
			prev = p[i]
			nxt = p[i]
		sort_range.append((prev, nxt))
		for (prev, nxt) in sort_range:
			part_sort(arr, prev, nxt)
		ans = 'YES'
		for i in range(len(arr) - 1):
			if arr[i] > arr[i + 1]:
				ans = 'NO'
				break
		print(ans)
sol()


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi
import math
from itertools import permutations
from copy import deepcopy

def main():
	for t in range(int(input())):
		(n, m) = map(int, input().split())
		a = [int(i) for i in input().split()]
		p = sorted(map(int, input().split()))
		z = 0
		ans = 'NO'
		while z < 100:
			for i in p:
				i -= 1
				if a[i] > a[i + 1]:
					(a[i], a[i + 1]) = (a[i + 1], a[i])
			f = 1
			for i in range(n - 1):
				if a[i] > a[i + 1]:
					f = 0
					break
			if f:
				ans = 'YES'
				break
			z += 1
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = [0] * n
	for i in a:
		p[i - 1] = 1
	i = 0
	while i < n:
		if not p[i]:
			i += 1
			continue
		j = i
		while j < n and p[j]:
			j += 1
		arr[i:j + 1] = sorted(arr[i:j + 1])
		i = j
		i += 1
	if arr == sorted(arr):
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = sorted(list(map(int, input().split())))
	foundSwap = True
	while foundSwap:
		foundSwap = False
		for i in p:
			if a[i - 1] > a[i]:
				foundSwap = True
				temp = a[i]
				a[i] = a[i - 1]
				a[i - 1] = temp
	if a == sorted(a):
		print('YES')
	else:
		print('NO')


def main():
	op = ''
	t = int(input())
	for i in range(t):
		(len_ip, len_pos) = map(int, input().split(' '))
		ip = [int(item) for item in input().split(' ')]
		pos = [int(item) for item in input().split(' ')]
		op += check(ip, pos, len_ip, len_pos) + '\n'
	print(op)

def check(ip, pos, len_ip, len_pos):
	temp = 0
	for i in range(len_ip):
		for j in range(0, len_ip - 1 - i):
			if ip[j] > ip[j + 1]:
				if not j + 1 in pos:
					return 'NO'
				temp = ip[j]
				ip[j] = ip[j + 1]
				ip[j + 1] = temp
	return 'YES'
main()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	sorta = a.copy()
	sorta.sort()
	p = list(map(int, input().split()))
	flag = -1
	for k in range(n):
		j = 0
		while True:
			if j == n - 1:
				break
			if a == sorta:
				flag = 1
				break
			if a[j] > a[j + 1]:
				if j + 1 in p:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
					j += 1
				else:
					flag = 0
					break
				if a == sorta:
					flag = 1
					break
			else:
				j += 1
		if flag == 1:
			print('YES')
			break
		if flag == 0:
			print('NO')
			break


t = int(input())
while t:
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = [int(a) for a in input().split()]
	p = [int(p) for p in input().split()]
	p.sort()
	a1 = sorted(a)
	left = p[0] - 1
	for i in range(1, m):
		if p[i] - p[i - 1] > 1:
			right = p[i - 1] + 1
			a[left:right] = sorted(a[left:right])
			left = p[i] - 1
	right = p[m - 1] + 1
	a[left:right] = sorted(a[left:right])
	if a1 == a:
		print('YES')
	else:
		print('NO')
	t = t - 1


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def inn():
	return int(input())
t = inn()
while t:
	t -= 1
	(n, m) = value()
	a = arr()
	way = arr()
	way.sort()
	val = []
	i = 0
	while i < m:
		j = way[i]
		res = way[i]
		while i < m and way[i] == j:
			i += 1
			j += 1
		val += [(res - 1, j - 1)]
	res = 1
	for i in range(n - 1):
		temp = i
		for j in range(i + 1, n):
			if a[j] < a[temp]:
				temp = j
		if temp != i:
			x = i
			y = temp
			flag = 0
			for j in range(len(val)):
				if val[j][0] <= x and val[j][1] >= y:
					flag = 1
					break
			if flag == 0:
				res = 0
				break
			(a[i], a[temp]) = (a[temp], a[i])
	if res == 0:
		print('NO')
	else:
		print('YES')


import bisect
for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	l = [0 for i in range(n)]
	for i in p:
		l[i - 1] = 1
	while True:
		f = False
		for i in range(n):
			if l[i] and a[i] > a[i + 1]:
				f = True
				(a[i], a[i + 1]) = (a[i + 1], a[i])
		if f == False:
			break
	f = True
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


def solve(integers, positions):
	valid = {}
	goal = sorted(integers)
	for i in range(1, len(integers)):
		if i in positions:
			valid[i] = True
		else:
			valid[i] = False
	while True:
		for i in range(len(integers) - 1):
			if integers[i] > integers[i + 1]:
				if not valid[i + 1]:
					return False
				else:
					(integers[i], integers[i + 1]) = (integers[i + 1], integers[i])
			if integers == goal:
				return True
t = int(input())
for x in range(t):
	info = input().split()
	(n, m) = (int(info[0]), int(info[1]))
	ints = input().split()
	ints = [int(i) for i in ints]
	positions = input().split()
	positions = [int(p) for p in positions]
	if solve(ints, positions):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	n = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	l = []
	l2 = []
	flg = 0
	for i in range(len(p)):
		if i < len(p) - 1 and p[i + 1] - 1 == p[i]:
			l2.append(p[i])
			flg = 1
		elif flg == 1:
			l2.append(p[i])
			flg = 0
			l.append(l2)
			l2 = []
		else:
			l.append([p[i]])
	n2 = n.copy()
	n.sort()
	for i in l:
		if len(i) > 1:
			x = n2[i[0] - 1:i[len(i) - 1] + 1]
			x.sort()
			n2[i[0] - 1:i[len(i) - 1] + 1] = x
		else:
			x = n2[i[0] - 1:i[0] + 1]
			x.sort()
			n2[i[0] - 1:i[0] + 1] = x
	if n == n2:
		print('YES')
	else:
		print('NO')


def f(a, p, n, m):
	d = []
	for i in range(n - 1):
		for j in range(0, n - i - 1):
			if a[j] > a[j + 1]:
				d.append(j + 1)
				t = a[j]
				a[j] = a[j + 1]
				a[j + 1] = t
	if set(d).issubset(set(p)):
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	f(a, p, n, m)


q = int(input())
for i in range(q):
	(n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	p = set([int(i) for i in input().split()])
	f = 0
	for i in range(n):
		for j in range(n - 1):
			if a[j] > a[j + 1]:
				if j + 1 not in p:
					print('NO')
					f = 1
					break
				else:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
		if f == 1:
			break
	if f == 1:
		continue
	print('YES')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	a = sorted(arr)
	p.sort()
	for i in range(n):
		for j in p:
			arr[j - 1:j + 1] = sorted(arr[j - 1:j + 1])
	if arr == a:
		print('YES')
	else:
		print('NO')


t = int(input())
for x in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	f = [[]]
	b = [0] * n
	for x in p:
		b[x - 1] = 1
	for x in range(n):
		f[-1].append(a[x])
		if b[x] == 0:
			f.append([])
	if f[-1] == []:
		f.pop()
	a.sort()
	g = []
	for x in f:
		g += sorted(x)
	if a == g:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = a[:]
	b.sort()
	p = list(map(int, input().split()))
	flg = 1
	while flg:
		flg = 0
		for i in p:
			if a[i - 1] > a[i]:
				temp = a[i - 1]
				a[i - 1] = a[i]
				a[i] = temp
				flg = 1
	cnt = 0
	for i in range(n):
		if a[i] == b[i]:
			cnt += 1
	if cnt == n:
		print('YES')
	else:
		print('NO')
	t -= 1


class union_find:

	def __init__(self, n):
		self.n = n
		self.rank = [0] * n
		self.parent = [int(j) for j in range(n)]

	def union(self, i, j):
		i = self.find(i)
		j = self.find(j)
		if self.rank[i] == self.rank[j]:
			self.parent[i] = j
			self.rank[j] += 1
		elif self.rank[i] > self.rank[j]:
			self.parent[j] = i
		else:
			self.parent[i] = j

	def find(self, i):
		temp = i
		if self.parent[temp] != temp:
			self.parent[temp] = self.find(self.parent[temp])
		return self.parent[temp]
for t in range(int(input())):
	(a, b) = [int(j) for j in input().split()]
	l = [int(j) for j in input().split()]
	p = [int(j) - 1 for j in input().split()]
	p.sort(reverse=True)
	p_ = [i for i in p]
	x = union_find(a)
	for i in range(b):
		x.union(p[i], p[i] + 1)
	flag = True
	for i in range(a):
		for j in range(i + 1, a):
			if l[i] > l[j]:
				if x.find(i) != x.find(j):
					print('NO')
					flag = False
					break
		if flag == False:
			break
	else:
		print('YES')


def main():
	t = int(input())
	for __ in range(t):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		flag = False
		while True:
			swap_occur = False
			for i in b:
				if a[i - 1] > a[i]:
					temp = a[i]
					a[i] = a[i - 1]
					a[i - 1] = temp
					swap_occur = True
			if not swap_occur:
				break
		for i in range(n - 1):
			if a[i] > a[i + 1]:
				flag = True
				break
		if flag:
			print('NO')
		else:
			print('YES')
main()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	mlist = list(map(int, input().split()))
	mlist.sort()
	for l in range(len(mlist)):
		mlist[l] -= 1
	s = set(mlist)
	segs = []
	x = []
	for j in range(len(a)):
		if j not in s:
			x.append(a[j])
			segs.append(x)
			x = []
		else:
			x.append(a[j])
	mins = []
	for p in segs:
		mins.append([min(p), max(p)])
	fflag = 0
	for k in range(len(mins)):
		for j in range(k + 1, len(mins)):
			if mins[j][0] < mins[k][1]:
				fflag = 1
				break
		if fflag == 1:
			break
	if fflag == 1:
		print('NO')
	else:
		print('YES')


import copy
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = [int(x) for x in input().split()]
	a = [int(z) for z in input().split()]
	a.sort()
	start = a[0] - 1
	x = []
	for i in range(m - 1):
		if a[i] != a[i + 1] - 1:
			for p in range(start, a[i] + 1):
				for q in range(p + 1, a[i] + 1):
					if l[p] > l[q]:
						(l[p], l[q]) = (l[q], l[p])
			start = a[i + 1] - 1
	for p in range(start, min(a[m - 1] + 1, n)):
		for q in range(p + 1, min(a[m - 1] + 1, n)):
			if l[p] > l[q]:
				(l[p], l[q]) = (l[q], l[p])
	xx = copy.deepcopy(l)
	xx.sort()
	if l == xx:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	flag = 0
	for i in range(n):
		check = 0
		for j in range(n - i - 1):
			if a[j + 1] < a[j]:
				if j + 1 not in l2:
					flag = 1
					break
				elif j + 1 in l2:
					check = 1
					(a[j + 1], a[j]) = (a[j], a[j + 1])
		if check == 0:
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


N = int(input())
y = []
for i in range(N):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	x = sorted(a)
	a_pre = []
	flag = False
	while flag == False:
		for i in p:
			if a[i - 1] > a[i]:
				(a[i - 1], a[i]) = (a[i], a[i - 1])
				if a == x:
					flag = True
					y.append('YES')
					break
			else:
				if a == x:
					flag = True
					y.append('YES')
					break
				if i == p[-1]:
					if a_pre == a:
						flag = True
						y.append('NO')
						break
					else:
						a_pre = a.copy()
for j in y:
	print(j)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	P = list(map(int, input().split()))
	t = 0
	B = A.copy()
	B.sort()
	flag = 0
	t = 0
	for i in range(n):
		ind = A.index(B[i])
		A[ind] = -1
		if ind == i:
			continue
		else:
			for j in range(i + 1, ind + 1):
				if j not in P:
					flag = 1
					break
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for loop in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	p = list(map(int, input().split()))
	p.sort()
	nq = []
	ans = []
	flag = 0
	for i in range(n):
		if i + 1 in p:
			flag = 1
			nq.append(a[i])
		elif flag == 1:
			nq.append(a[i])
			nq.sort()
			ans += nq
			nq = []
			flag = 0
		else:
			ans.append(a[i])
	a.sort()
	flag = True
	for i in range(n):
		if ans[i] != a[i]:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


def solve(na, mp, a, p):
	p.sort()
	sorted_a = sorted(a)
	made_swap = True
	while made_swap:
		made_swap = False
		for pi in p:
			try:
				if a[pi] > a[pi + 1]:
					(a[pi], a[pi + 1]) = (a[pi + 1], a[pi])
					made_swap = True
			except Exception as e:
				pass
	return sorted_a == a
for _ in range(int(input())):
	(na, mp) = map(int, input().split())
	a = [int(i) for i in input().split()]
	p = [int(i) - 1 for i in input().split()]
	if solve(na, mp, a, p):
		print('YES')
	else:
		print('NO')


TC = int(input())

def solve(arr, pos):
	pos_set = set(pos)
	for _ in range(len(arr)):
		for i in range(len(arr) - 1):
			if arr[i] > arr[i + 1] and i in pos_set:
				(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
	return arr == sorted(arr)
for _ in range(TC):
	(n, m) = map(int, input().split())
	(*arr,) = map(int, input().split())
	(*pos,) = [int(v) - 1 for v in input().split()]
	print('YES' if solve(arr, pos) else 'NO')


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write

def swap(i):
	t = a[i]
	a[i] = a[i + 1]
	a[i + 1] = t
for _ in range(int(cin())):
	(n, m) = map(int, cin().split())
	a = list(map(int, cin().split()))
	p = list(map(int, cin().split()))
	v = [0] * n
	for val in p:
		v[val - 1] = 1
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			if v[i]:
				swap(i)
				f = 0
				for j in range(i, 0, -1):
					if a[j - 1] > a[j]:
						if v[j - 1]:
							swap(j - 1)
						else:
							f = 1
							break
					else:
						break
				if f:
					cout('NO\n')
					break
			else:
				cout('NO\n')
				break
	else:
		cout('YES\n')