func main() var n: int :: cui@inputInt() var m: int :: cui@inputInt() var s: int :: cui@inputInt() var g: int :: cui@inputInt() var f: []int :: #[m]int var t: []int :: #[m]int for i(0, m - 1) do f[i] :: cui@inputInt() do t[i] :: cui@inputInt() end for var u: int :: cui@inputInt() var ng: dict :: #dict for(1, u) var i: int :: cui@inputInt() do ng.add(i, true) end for var uni: UnionFind :: (#UnionFind).init(n + 1) for i(0, m - 1) if(!ng.get(f[i], &) & !ng.get(t[i], &)) do uni.unite(f[i], t[i]) end if end for var ans: bool :: uni.same(s, g) do cui@print((ans ?("Yes", "No")) ~ "\n") class UnionFind() var parents: []int +func init(n: int): UnionFind do me.parents :: [-1].repeat(n) ret me end func +func size(x: int): int ret -me.parents[me.root(x)] end func +func same(x: int, y: int): bool ret me.root(x) = me.root(y) end func +func unite(x: int, y: int): bool do x :: me.root(x) do y :: me.root(y) if(x = y) ret false end if if(me.size(x) < me.size(y)) do me.parents[y] :+ me.parents[x] do me.parents[x] :: y else do me.parents[x] :+ me.parents[y] do me.parents[y] :: x end if ret true end func func root(x: int): int if(me.parents[x] < 0) ret x else do me.parents[x] :: me.root(me.parents[x]) ret me.parents[x] end if end func end class end func