Messy Kevin X


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C++, Java, Python

Kevin's been studying hard to go from being messy and clumsy to being knowledgeable and organised. He's been grinding data structures and algorithms study and has been diligently practicing LeetCodes every day. He's even participated in a few AUCPL rounds!

Feeling more confident about his ability to get (and retain) a job, he has started looking at job openings. All of the jobs he is applying to seem to have some requirements for applying, so Kevin decides to create a directed acyclic graph of different things he needs to learn and also achieve before he can apply. Each node of the graph represents a task that must be achieved and each task has some prerequisites.

Given the starting point, what is the minimum of tasks he needs to complete to reach the end goal?

Input

The first line contains integers n (1 \leq n \leq 10^5) and m (1 \leq m \leq 2 \times 10^5), the nodes and directed edges of the graph.

The next m lines contain two integers u and v (1 \leq u, v \leq n), a directed edge that goes from node u to node v. Note that the nodes are numbered 1 through n.

The last two lines consist of v_1 and v_n, the start and end node.

Output

Output the minimum number of tasks Kevin must complete to reach the goal. If there is no valid path from the start to the end, output -1.

Example

Input 1
5 4
1 2
1 3
2 4
3 5
1
5
Output 1
3

Kevin starts at task 1 and wants to reach task 5. A valid progression path is 1 \rightarrow 3 \rightarrow 5. Kevin therefore completes 3 tasks.

Input 2
4 2
1 2
2 3
1
4
Output 2
-1

There is no way to get from task 1 to task 4.


Comments

There are no comments at the moment.