AT_abc388_f [ABC388F] Dangerous Sugoroku
Description
There are $ N $ squares arranged in a row, labeled $ 1, 2, \ldots, N $ from left to right.
You are given $ M $ pairs of integers $ (L_1, R_1), \ldots, (L_M, R_M) $ .
A square $ j $ is defined to be **bad** if and only if there exists some $ i $ such that $ L_i \leq j \leq R_i $ .
Determine whether you can move from square $ 1 $ to square $ N $ by repeatedly performing the following action:
- Let your current square be $ x $ . Choose an integer $ i $ that satisfies all of the following conditions, and move to square $ x + i $ .
- $ A \leq i \leq B $
- $ x + i \leq N $
- Square $ x + i $ is not bad.
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ M $ $ A $ $ B $ $ L_1 $ $ R_1 $ $ L_2 $ $ R_2 $ $ \vdots $ $ L_M $ $ R_M $
Output Format
If it is possible to reach square $ N $ by repeating the action described in the problem statement, print `Yes`. Otherwise, print `No`.
Explanation/Hint
### Sample Explanation 1
You can move to square $ N $ in this way: $ 1 \to 6 \to 9 \to 12 \to 16 \to 21 \to 24 $ .
### Constraints
- $ 2 \leq N \leq 10^{12} $
- $ 0 \leq M \leq 2 \times 10^4 $
- $ 1 \leq A \leq B \leq 20 $
- $ 1 < L_i \leq R_i < N \ (1 \leq i \leq M) $
- $ R_i < L_{i+1} \ (1 \leq i \leq M - 1) $
- All input values are integers.