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: introductory

Starter code:

Solutions:
for _ in range(int(input())):
    n, m = list(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 T in range(t):
    n, m = list(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")



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")



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()))
    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()

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')

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())
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())

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")


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")


for _ in range(int(input())):
    n, m = list(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)
        else:
            if 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())
    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)])

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")

for nt in range(int(input())):
	n,m=list(map(int,input().split()))
	arr=list(map(int,input().split()))
	p=list(map(int,input().split()))
	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")


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")


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")


q = int(input())
for rwre in range(q):
	n,m = list(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")


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 = list(map(int, input().split()))
    a = list(map(int, input().split()))
    pos = sorted([int(x)-1 for x in 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')


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)

import sys
input = sys.stdin.readline

t=int(input())

for tests in range(t):
    n,m=list(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
                #print(i,top)
                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=list(map(int,input().split()))
    a=list(map(int,input().split()))
    p=list(map(int,input().split()))
    while 1:
        b=a.copy()
        for i in p:
            if a[i-1]>a[i]:
                a[i-1],a[i]=a[i],a[i-1]
        #print(a)
        if b==a:
            break
    b=a.copy()
    b.sort()
    if b==a:
        print("YES")
    else:
        print("NO")