아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Permutation Compression

시간 제한1초메모리 제한1024 MB

요약
순열과 목표 배열이 주어질 때, 각 도구가 정해진 길이 구간의 최댓값을 한 번씩 지울 수 있다면 사이 원소를 모두 지워 목표 배열을 만들 수 있는지 판정한다.
난이도

보통10점 중 7점

유형
스택, 그리디, 구현, 정렬
정답자
아직 제출이 없습니다

문제

Grammy has a permutation of length nn. She wants to delete some useless elements in the permutation, so she decided to use some magic tool to delete them. There are kk magic tools, the ii-th of them can delete the maximum element of an interval of length exactly ℓ_i\ell\_i. 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 mm distinct elements from 11 to nn. 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 TT (1≤T≤1051 \leq T \leq 10^5), denoting the number of test cases.

For each test case:

The first line contains three integers nn, mm, kk (1≤m≤n≤2⋅1051 \leq m \leq n \leq 2 \cdot 10^5, 1≤k≤2⋅1051\leq k\leq 2\cdot 10^5), denoting the length of the permutation, the length of the compressed array, and the parameter of the magic tool.

The second line contains nn distinct integers a_ia\_i (1≤a_i≤n1 \leq a\_i \leq n), denoting the initial permutation. It is guaranteed that the elements are distinct.

The third line contains mm distinct integers b_ib\_i (1≤b_i≤n1 \leq b\_i \leq n), denoting the array after compression. It is guaranteed that the elements are distinct.

The fourth line contains kk integers ℓ_i\ell\_i (1≤ℓ_i≤n1 \leq \ell\_i \leq n), denoting the magic tools.

It is guaranteed that ∑n≤2⋅105\sum n\leq 2\cdot 10^5 and ∑k≤2⋅105\sum k\leq 2\cdot 10^5.

출력

For each test case, output "YES" or "NO" on a separate line, denoting the answer to the problem.

예제1

  1. 예제 1

    입력
    3
    5 2 3
    5 1 3 2 4
    5 2
    1 2 4
    5 5 5
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    3 2 2
    3 1 2
    3 2
    2 3
    
    예상 출력
    YES
    YES
    NO