atcoder#ARC154C. [ARC154C] Roller
[ARC154C] Roller
Score : points
Problem Statement
You are given sequences of positive integers of length : and .
You can repeat the following operation any number of times (possibly zero).
- Choose an integer such that and replace with .
Here, regard as .
Determine whether it is possible to make equal .
You have test cases to solve.
Constraints
- For each input file, the sum of over all test cases does not exceed .
Input
The input is given from Standard Input in the following format:
Each test case is in the following format:
Output
Print lines.
The -th line should contain Yes
if it is possible to make equal in the -th test case, and No
otherwise.
3
2
1 2
2 2
4
2 3 1 1
2 1 1 2
2
1 1
2 2
Yes
Yes
No
In the first test case, you can make equal as follows.
- Choose to replace with , making .
In the second test case, you can make equal as follows.
- Choose to replace with , making .
- Choose to replace with , making .
In the third test case, there is no way to make equal .