10331: ABC355 —— B - Piano 2
[Creator : ]
Description
You are given a sequence $A=(A_1,A_2,\dots,A_N)$ of length $N$ and a sequence $B=(B_1,B_2,\dots,B_M)$ of length $M$. Here, all elements of $A$ and $B$ are pairwise distinct. Determine whether the sequence $C=(C_1,C_2,\dots,C_{N+M})$ formed by sorting all elements of $A$ and $B$ in ascending order contains two consecutive elements appearing in $A$.
Input
The input is given from Standard Input in the following format:
```
$N$ $M$
$A_1$ $A_2$ $\dots$ $A_N$
$B_1$ $B_2$ $\dots$ $B_M$
```
```
$N$ $M$
$A_1$ $A_2$ $\dots$ $A_N$
$B_1$ $B_2$ $\dots$ $B_M$
```
Output
If $C$ contains two consecutive elements appearing in $A$, print `Yes`; otherwise, print `No`.
Constraints
- $1 \leq N, M \leq 100$
- $1 \leq A_i, B_j \leq 200$
- $A_1, A_2, \dots, A_N, B_1, B_2, \dots, B_M$ are distinct.
- All input values are integers.
- $1 \leq A_i, B_j \leq 200$
- $A_1, A_2, \dots, A_N, B_1, B_2, \dots, B_M$ are distinct.
- All input values are integers.
Sample 1 Input
3 2
3 2 5
4 1
Sample 1 Output
Yes
C=(1,2,3,4,5). Since 2 and 3 from A occur consecutively in C, print Yes.
Sample 2 Input
3 2
3 1 5
4 2
Sample 2 Output
No
C=(1,2,3,4,5). Since no two elements from A occur consecutively in C, print No.
Sample 3 Input
1 1
1
2
Sample 3 Output
No