3074: Re: Trial of Devil

时间限制:2000 ms 内存限制:128 MB
上传者:
提交:3 通过:2

题目描述

If you pass the previous trial of Devil Aguin, congratulations to you! But the real trial has just begun. This time, Devil Aguin provides you a sequence $A$ consisting of $n$ elements and a value $k$. Then he also offers you an operation to process the sequence.

What you can do in one operation are as following :
  1. Select a $k$-length interval of $A$ arbitrarily.
  2. Select a positive integer $x$ arbitrarily.
  3. Turn element whose value is no more than $x$ in the interval to $0$.
You can perform the operation as much as you like. It is clear that, when you perform the operation, the elements in $A$ may be developed into $0$ one by one. Now Devil Aguin gives you an order sequence $C$, which contains $m$ elements ranging from $1$ to $n$. He requires that for each $x(1 \leq x \leq m)$, the $C_{x}$-th element in $A$ must turn to $0$. And generally, for every $i,j(i<j)$, the time $C_{i}$-th element in $A$ turning to $0$ must be strictly earlier than $C_{j}$-th element.

Please judge if it is possible to meet the requirement.

It is guaranteed that there is no same element in $C$.

输入格式

The first line contains an integer number T, the number of test cases.

For each test case :

The first line contains three integers $n$, $m$, $k$($1 \leq n \leq 10^{5}, 1 \leq m,k \leq n$), the number of $A$, the number of $C$ and the value of $k$.

The second line contains $n$ integers $A_{i}$($1 \leq A_{i} \leq 10^{6}$).

The third line contains $m$ integers $C_{i}$($1 \leq C_{i} \leq n$).

输出格式

For each test case print“YES”(without quotes) if it is possible, and“NO”(without quotes) otherwise.

输入样例 复制

2
5 3 2
2 5 6 5 3
2 3 4
5 3 2
2 5 6 5 3
3 2 4

输出样例 复制

YES
NO