Permutation Compression
시간 제한1초메모리 제한1024 MB
순열과 목표 배열이 주어질 때, 각 도구가 정해진 길이 구간의 최댓값을 한 번씩 지울 수 있다면 사이 원소를 모두 지워 목표 배열을 만들 수 있는지 판정한다.
문제
Grammy has a permutation of length . She wants to delete some useless elements in the permutation, so she decided to use some magic tool to delete them. There are magic tools, the -th of them can delete the maximum element of an interval of length exactly . Each magic tool can be used at most once.
After each deletion, the length of the array decreases by one, and the neighbors of the deleted element become neighbors themselves.
Before using the tool, Grammy shows you her blueprint of the array after deletion. The new array consists of exactly distinct elements from to . Please help Grammy to determine whether it is possible to delete the elements by using the magic tool, so that the result is equal to the blueprint.
입력
There are multiple test cases.
The first line contains an integer (), denoting the number of test cases.
For each test case:
The first line contains three integers , , (, ), denoting the length of the permutation, the length of the compressed array, and the parameter of the magic tool.
The second line contains distinct integers (), denoting the initial permutation. It is guaranteed that the elements are distinct.
The third line contains distinct integers (), denoting the array after compression. It is guaranteed that the elements are distinct.
The fourth line contains integers (), denoting the magic tools.
It is guaranteed that and .
출력
For each test case, output "YES" or "NO" on a separate line, denoting the answer to the problem.