#codefestival2016qualAe. [codefestival_2016_qualA_e]LRU Puzzle
[codefestival_2016_qualA_e]LRU Puzzle
Problem Statement
There are arrays. The length of each array is and initially each array contains integers in this order.
Mr. Takahashi has decided to perform operations on those arrays. For the -th () time, he performs the following operation.
- Choose an arbitrary array from the arrays and move the integer () to the front of that array. For example, after performing the operation on and the array , this array becomes .
Mr. Takahashi wants to make arrays exactly the same after performing the operations. Determine if it is possible or not.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if it is possible to make arrays exactly the same after performing the operations. Otherwise, print No
.
Sample Input 1
2 2
3
2 1 2
Sample Output 1
Yes
You can perform the operations as follows.
Sample Input 2
3 2
3
2 1 2
Sample Output 2
No
Sample Input 3
2 3
3
3 2 1
Sample Output 3
Yes
You can perform the operations as follows.
Sample Input 4
3 3
6
1 2 2 3 3 3
Sample Output 4
No