Task
Valerio is trying to escape from a bank that he has robbed. An alarm has gone off and the police are searching for him. Valerio needs to get out as fast as possible through the sewer tunnels that run near the bank. There is only one police patrol that has been sent to guard the manholes connected to the sewer system.
There are manholes, indexed from to , and tunnels connecting manholes and . Valerio's friend Filippo is waiting for him near manhole , and if Valerio can reach it, he will escape safely. Valerio starts from manhole and can choose to move to a manhole adjacent to the one he is in or to stay another minute under the same manhole. The police patrol is initially guarding manhole , and every minute it moves from manhole to manhole , after reaching manhole , it returns to manhole .
Help Valerio to escape from the bank!
Input
The first line contains the integers (), (), ().
The next lines contain the integers , ().
The next line contains integers: ()
for all .
It's guaranteed that there is a path from manhole to manhole .
For tests worth points: .
For tests worth points: The tunnels form a line starting from manhole and ending in manhole .
For tests worth points: No additional limitations.
Output
You need to write a single line with an integer: the minimum amount of minutes needed to get from manhole to manhole .
stdin
5 6 3
0 1
2 3
3 0
2 0
2 4
1 3
4 2 3
stdout
4
stdin
7 10 5
2 6
1 4
2 5
0 5
3 4
5 3
4 0
3 2
1 5
4 6
2 4 1 6 5
stdout
4
Notes
In the first sample case Valerio can reach manhole in 4 steps:
- He waits minute in manhole and the guard moves to manhole .
- He moves to manhole and the guard moves to manhole .
- He waits minute in manhole and the guard moves to manhole .
- He moves to manhole and the guard moves to manhole .
In the {second sample case Valerio can reach manhole in 4 steps:
- He waits minute in manhole and the guard moves to manhole .
- He moves to manhole and the guard moves to manhole .
- He waits minute in manhole and the guard moves to manhole .
- He moves to manhole and the guard moves to manhole .