Sequence
면접 대비시간 제한1초메모리 제한512 MB
색깔 공의 초기 배열과 목표 배열이 주어지고, 여러 구간 재배치 연산을 순서대로 적용해 목표 배열에 도달할 수 있는지 판정한다.
문제
ZZX has a sequence of boxes numbered . Each box can contain at most one ball.
You are given the initial configuration of the balls. For , if the -th box is empty, then , otherwise the -th box contains exactly one ball, the color of which is , a positive integer. Balls of the same color cannot be distinguished.
ZZX will perform operations in order. During -th operation, he collects all the balls from boxes , and then arbitrarily puts them back into these boxes. Note that each box should always contain at most one ball.
ZZX wants to change the configuration of the balls from to using these operations. Please tell ZZX whether it is possible to achieve his goal.
입력
The first line contains an integer . Then test cases follow. In each test case:
The first line of the test case contains two integers and (, , sum of over all test cases does not exceed , sum of over all test cases does not exceed ).
The second line contains (). The third line contains (). Each of the next lines contains two integers and ().
출력
For each test case, print "Yes" or "No" on a separate line.