#abc289d. [abc289_d]Step Up Robot
[abc289_d]Step Up Robot
Problem Statement
There is a staircase with infinite steps. The foot of the stairs is the -th step, the next step is the -st step, the next is the -nd, and so on.
There is a stair-climbing robot on the -th step. The robot can climb up , or steps at a time. In other words, when the robot is on the -th step, it can step onto one of the -th step, -th step, , and -th step, but not onto the others in a single step. The robot cannot descend the stairs, either.
There are traps on the -th, -th, , and -th steps. Once the robot steps onto a step with a trap, it cannot move anymore.
The robot wants to step onto the -th step. Determine whether it is possible to do so.
Constraints
- $1\\leq A _ 1\\lt A _ 2\\lt\\cdots\\lt A _ N\\leq10^5$
- $1\\leq B _ 1\\lt B _ 2\\lt\\cdots\\lt B _ M\\lt X\\leq10^5$
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
In a single line, print Yes
if the robot can step onto the -th step, and No
otherwise.
Sample Input 1
3
3 4 5
4
4 5 6 8
15
Sample Output 1
Yes
For example, the robot can reach the -th step as follows.
- Climb up steps. The robot is now on the -rd step.
- Climb up steps. The robot is now on the -th step.
- Climb up steps. The robot is now on the -th step.
- Climb up steps. The robot is now on the -th step.
Sample Input 2
4
2 3 4 5
4
3 4 5 6
8
Sample Output 2
No
No matter how the robot moves, it cannot step onto the -th step.
Sample Input 3
4
2 5 7 8
5
2 9 10 11 19
20
Sample Output 3
Yes