Email Filing
시간 제한2초메모리 제한1024 MB
순서대로 주어진 N개의 이메일을 각각 정해진 폴더에 넣어야 하며, 아래로만 스크롤되는 K 크기 창에서 마지막 이메일을 처리하면 위로 한 칸 이동하는 효과가 생긴다. 모든 이메일을 처리할 수 있는지 판정한다.
문제
Farmer John has fallen behind on organizing his inbox. The way his screen is organized, there is a vertical list of folders on the left side of the screen and a vertical list of emails on the right side of the screen. There are total folders, numbered (. His inbox currently contains emails numbered (); the th email needs to be filed into folder ().
FJ's screen is rather small, so he can only view () folders and emails at once. Initially, his screen starts out displaying folders on the left and emails on the right. To access other folders and emails, he needs to scroll through these respective lists. For example, if he scrolls down one position in the list of folders, his screen will display folders , and then scrolling down one position further it will display folders . When FJ drags an email into a folder, the email disappears from the email list, and the emails after the one that disappeared shift up by one position. For example, if emails are currently displayed and FJ drags email 3 into its appropriate folder, the email list will now show emails . FJ can only drag an email into the folder to which it needs to be filed.
Unfortunately, the scroll wheel on FJ's mouse is broken, and he can only scroll downwards, not upwards. The only way he can achieve some semblance of upward scrolling is if he is viewing the last set of emails in his email list, and he files one of these. In this case, the email list will again show the last emails that haven't yet been filed, effectively scrolling the top email up by one. If there are fewer than emails remaining, then all of them will be displayed.
Please help FJ determine if it is possible to file all of his emails.
입력
The first line of input contains (), the number of subcases in this input, all of which must be solved correctly to solve the input case. The subcases then follow. For each subcase, the first line of input contains , , and . The next line contains .
It is guaranteed that the sum of over all subcases does not exceed , and that the sum of over all subcases does not exceed .
출력
Output lines, each one either containing either YES or NO, specifying whether FJ can successfully file all his emails in each of the subcases.