import scala.collection.mutable import scala.io.StdIn.* import scala.math.min @main def main = val Array(n, m) = readLine().split(' ').map(_.toInt) val Array(s, g) = readLine().split(' ').map(_.toInt - 1) val edges = Array.fill(m){ val Array(f, t) = readLine().split(' ').map(_.toInt - 1) (f, t) } val graph = Array.fill(n){Nil: List[Int]} for (f, t) <- edges do graph(f) ::= t val u = readLine().toInt val closed = if u > 0 then readLine().split(' ').map(_.toInt - 1) else Array[Int]() val visit = Array.fill(n){false} val stack = mutable.ArrayDeque[Int]().addOne(s) visit(s) = true for i <- closed do visit(i) = true while stack.nonEmpty do val current = stack.removeLast() for next <- graph(current) do if !visit(next) then visit(next) = true stack.addOne(next) println(if (visit(g)) "Yes" else "No")