#C6069. Liquid Flow to Collection Containers

    ID: 49788 Type: Default 1000ms 256MiB

Liquid Flow to Collection Containers

Liquid Flow to Collection Containers

In a liquid distribution facility, the system is divided into \( n \) sections that are connected by directed pipes. Some of these sections are designated as collection containers. The liquid flows from one section to another through these pipes, and your task is to determine whether starting from a given section \( s \), the liquid can reach any of the collection containers.

The facility is modeled as a directed graph: each vertex represents a section and each directed edge represents a pipe from section \( u \) to section \( v \). If there exists a path from \( s \) to any section that is a collection container, output "YES"; otherwise, output "NO".

Input is provided via standard input and output should be printed to standard output.

inputFormat

The first line contains two integers \( n \) and \( m \), representing the number of sections and the number of pipes, respectively.

The next \( m \) lines each contain two integers \( u \) and \( v \), representing a directed pipe from section \( u \) to section \( v \).

The following line contains two integers \( s \) and \( k \), where \( s \) is the starting section and \( k \) is the number of collection containers.

The last line contains \( k \) space-separated integers, each indicating a section that is a collection container.

outputFormat

Output a single line containing "YES" if the liquid can reach a collection container, otherwise output "NO".

## sample
5 6
1 2
1 3
2 4
3 4
4 5
3 5
1 2
4 5
YES