#arc150c. [arc150_c]Path and Subsequence

[arc150_c]Path and Subsequence

Problem Statement

We have a connected undirected graph GG with NN vertices and MM edges. The vertices are numbered 11 to NN. The ii-th edge connects vertices UiU_i and ViV_i.

Additionally, we are given an integer sequence of length NN, A=(A1,A2,dots,AN)A=(A_1,\\ A_2, \\dots,\\ A_N), and an integer sequence of length KK, B=(B1,B2,dots,BK)B=(B_1,\\ B_2,\\ \\dots,\\ B_K).

Determine whether GG, AA, and BB satisfy the following condition.

  • For every simple path from vertex 11 to NN in GG, v=(v1,v2,dots,vk)(v1=1,vk=N)v=(v_1,\\ v_2, \\dots,\\ v_k)\\ (v_1=1,\\ v_k=N), BB is a (not necessarily contiguous) subsequence of (Av1,Av2,dots,Avk)(A_{v_1},\\ A_{v_2},\\ \\dots,\\ A_{v_k}).

Constraints

  • 2leqNleq1052 \\leq N \\leq 10^5
  • 1leqKleqN1 \\leq K \\leq N
  • N1leqMleq2times105N-1 \\leq M \\leq 2 \\times 10^5
  • 1leqUi<VileqN1 \\leq U_i < V_i \\leq N
  • (Ui,Vi)neq(Uj,Vj)(U_i,\\ V_i) \\neq (U_j,\\ V_j) if ineqji \\neq j.
  • 1leqAi,BileqN1 \\leq A_i,\\ B_i \\leq N
  • All values in the input are integers.
  • The given graph GG is connected.

Input

The input is given from Standard Input in the following format:

NN MM KK U1U_1 V1V_1 U2U_2 V2V_2 vdots\\vdots UMU_M VMV_M A1A_1 A2A_2 dots\\dots ANA_N B1B_1 B2B_2 dots\\dots BKB_K

Output

If the condition is satisfied, print Yes; otherwise, print No.


Sample Input 1

6 6 3
1 2
1 3
2 4
3 5
4 6
5 6
1 2 4 5 2 6
1 2 6

Sample Output 1

Yes

There are two simple paths from vertex 11 to vertex 66: (1,2,4,6)(1,\\ 2,\\ 4,\\ 6) and (1,3,5,6)(1,\\ 3,\\ 5,\\ 6). The (Av1,Av2,dots,Avk)(A_{v_1},\\ A_{v_2},\\ \\dots,\\ A_{v_k}) corresponding to these paths are (1,2,5,6)(1,\\ 2,\\ 5,\\ 6) and (1,4,2,6)(1,\\ 4,\\ 2,\\ 6). Both of them have B=(1,2,6)B=(1,\\ 2,\\ 6) as a subsequence, so the answer is Yes.


Sample Input 2

5 5 3
1 2
2 3
3 4
4 5
2 5
1 2 3 5 2
1 3 2

Sample Output 2

No

For a simple path (1,2,5)(1,\\ 2,\\ 5) from vertex 11 to vertex 55, the (Av1,Av2,dots,Avk)(A_{v_1},\\ A_{v_2},\\ \\dots,\\ A_{v_k}) is (1,2,2)(1,\\ 2,\\ 2), which does not have B=(1,3,2)B=(1,\\ 3,\\ 2) as a subsequence.


Sample Input 3

10 20 3
5 6
5 10
5 7
3 5
3 7
2 6
3 8
4 5
5 8
7 10
1 6
1 9
4 6
1 2
1 4
6 7
4 8
2 5
3 10
6 9
2 5 8 5 1 5 1 1 5 10
2 5 1

Sample Output 3

Yes