AlgoUniversity
  • Go Back
Minimum Jumps :

Author

Sumeet Kumar Mishra

Difficulty Level : Easy

Submissions : 3206

Asked In :

Marks :10

: 62 | : 3

You are given $$$N$$$ buildings and $$$M$$$ pairs of building denoting which pair of buildings are close enough to jump from one another. Given current building you are at and final building where you want to be at, find out minimum number of jumps required.

If it is not possible to reach to final building, print $$$0$$$.

Input

First line contains two integers $$$N$$$ & $$$M$$$, denoting number of buildings and number of pairs of building that are close enough to jump from one another.

Next $$$M$$$ lines contain two integers each denoting buildings which are close enough.

Last line of input contains two integers denoting building you are starting at and building you want to reach.

Output

Print minimum number of jumps required to reach final building. If it is not possible then print "$$$0$$$".

Examples

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

Note

$$$1 \leq N \leq 4000$$$

$$$1 \leq M \leq 10^{6}$$$

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.