AT_abc481_d [ABC481D] Autopilot

Description

There are $ N $ planets and $ M $ routes. The planets are numbered $ 1 $ to $ N $ , and the routes are numbered $ 1 $ to $ M $ . Route $ i $ goes from planet $ A_i $ to planet $ B_i $ . Each route is one-way. A spaceship can perform the following two types of operations. - Move, without consuming fuel, to the planet with the smallest number among the planets directly reachable by a route from the current planet. - Choose any planet directly reachable by a route from the current planet, and move to the chosen planet, consuming $ 1 $ unit of fuel. Find the minimum amount of fuel the spaceship consumes to start from planet $ S $ and arrive at planet $ T $ . If it is impossible to reach planet $ T $ , print $ -1 $ instead.

Input Format

The input is given from Standard Input in the following format: > $ N $ $ M $ $ S $ $ T $ $ A_1 $ $ B_1 $ $ \vdots $ $ A_M $ $ B_M $

Output Format

Print the answer.

Explanation/Hint

### Sample Explanation 1 By moving in the following order, the spaceship can travel from planet $ 2 $ to planet $ 1 $ with a fuel consumption of $ 1 $ . 1. Move from planet $ 2 $ to planet $ 4 $ without consuming fuel. 2. Move from planet $ 4 $ to planet $ 3 $ , consuming $ 1 $ unit of fuel. 3. Move from planet $ 3 $ to planet $ 1 $ without consuming fuel. ### Sample Explanation 2 By moving in the following order, the spaceship can travel from planet $ 2 $ to planet $ 7 $ with a fuel consumption of $ 2 $ . 1. Move from planet $ 2 $ to planet $ 4 $ without consuming fuel. 2. Move from planet $ 4 $ to planet $ 2 $ without consuming fuel. 3. Move from planet $ 2 $ to planet $ 5 $ , consuming $ 1 $ unit of fuel. 4. Move from planet $ 5 $ to planet $ 6 $ without consuming fuel. 5. Move from planet $ 6 $ to planet $ 7 $ , consuming $ 1 $ unit of fuel. ### Sample Explanation 3 It is impossible to start from planet $ 1 $ and reach planet $ 2 $ . ### Constraints - $ 2 \leq N \leq 2 \times 10^5 $ - $ 1 \leq M \leq 2 \times 10^5 $ - $ 1 \leq S,T \leq N $ - $ S \neq T $ - $ 1 \leq A_i, B_i \leq N $ - $ A_i \neq B_i $ - All input values are integers.