Escape from... dolls 2 - MarisaOJ: Marisa Online Judge

Escape from... dolls 2

Time limit: 1000 ms
Memory limit: 256 MB
Marisa is again being chased by k Alice's dolls. Marisa is now at vertex 1 of an undirected graph of n vertices and m edges. The ith doll is at vertex Ai. Marisa and dolls can move to any adjacent vertex in 1 unit of time. Marisa can escape these dolls after reaching one of the p special vertices S1,S2,...,Sp. She does not want to encounter any doll on her path (encountering the dolls at the special vertices still counts). Determine if there exists a path that **in any case**, Marisa won't meet any doll. ### Input - The first line contains 4 integers n,m,k,p. - The second line contains k integers Ai. - The third line contains p integers Si. - The next m lines, each line contains 2 integers u,v, there is an edge between u and v. ### Output - Print YES if such a path exists, NO otherwise. ### Constraints - 1≤p,k≤n≤105. - 1≤m≤105. - 1≤u,v,Ai≤n. ### Example Input: 6621256121334244536 Output: YES