patrol2

Time limit: 0.5s Memory limit: 64MB Input: Output:

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 NN manholes, indexed from 00 to N1N - 1, and MM tunnels connecting manholes AiA_i and BiB_i. Valerio's friend Filippo is waiting for him near manhole N1N - 1, and if Valerio can reach it, he will escape safely. Valerio starts from manhole 00 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 C0C_0, and every minute it moves from manhole CiC_i to manhole Ci+1C_{i+1}, after reaching manhole CL1C_{L-1}, it returns to manhole C0C_0.

Help Valerio to escape from the bank!

Input

The first line contains the integers NN (1N100 0001 \le N \le 100\ 000), MM (1M100 0001 \le M \le 100\ 000), LL (2L100 0002 \le L \le 100\ 000).
The next MM lines contain the integers AiA_i, BiB_i (0Ai,Bi<N0 \le A_i, B_i < N).
The next line contains LL integers: C0,C1,...,CL1C_0, C_1, ..., C_{L-1} (1Ci<N1 \le C_i < N)

CiCjC_i \neq C_j for all iji \neq j.

It's guaranteed that there is a path from manhole 00 to manhole N1N - 1.

For tests worth 3030 points: N,M,L1000N, M, L \le 1000.

For tests worth 3030 points: The tunnels form a line starting from manhole 00 and ending in manhole N1N - 1.

For tests worth 4040 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 00 to manhole N1N - 1.

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 44 in 4 steps:

  • He waits 11 minute in manhole 00 and the guard moves to manhole 22.
  • He moves to manhole 22 and the guard moves to manhole 33.
  • He waits 11 minute in manhole 22 and the guard moves to manhole 44.
  • He moves to manhole 44 and the guard moves to manhole 22.

In the {second sample case Valerio can reach manhole 66 in 4 steps:

  • He waits 11 minute in manhole 00 and the guard moves to manhole 44.
  • He moves to manhole 44 and the guard moves to manhole 11.
  • He waits 11 minute in manhole 44 and the guard moves to manhole 66.
  • He moves to manhole 66 and the guard moves to manhole 55.

Log in or sign up to be able to send submissions!