Problem D
Bruinwalk
You woke up twenty minutes before your midterm, and now you’re gonna be late to class! You are rushing to class and you come to a section on Bruinwalk. Unfortunately, the people handing out flyers on Bruinwalk are trying to get you to buy something or check out a club, which you don’t have time for. Can you reach the other side of Bruinwalk while avoiding all the flyering people?
Bruinwalk is represented by a simple (no looping or parallel edges), connected, undirected graph. Each entity (which includes you and each flyering person) occupies starting nodes on this graph, and there is a goal node you are trying to reach (suppose it represents the classroom where your midterm is held in). Each entity is always occupying a node at any given time.
This problem involves discrete turns. At every turn, the following actions happen simultaneously

You either stay put or move along an edge to an adjacent node, with the goal of trying to reach the goal node

Each of the flyering people either stays put or moves along an edge to an adjacent node, with the goal of eventually intercepting you (i.e. occupying the same node as you at the end of a turn)
You and the flyering people know the shape of the graph and the location of the goal node. You and the flyering people also know the locations of each other at all times. Decide if it is possible for you to reach the goal node in a finitelength path whilst avoiding the flyering people at every turn. This includes the end of the turn in which you move along an edge to the goal node. Assume that the flyering people move in an optimal way (i.e. if there exists a way to ensure you are intercepted before reaching the goal node, then the flyering people know about it).
Input
The first line of input consists of two spaceseparated numbers $n$ and $m$, where $2 \leq n \leq 1\, 000$ is the number of vertices in the graph, and $0 \leq m \leq \frac{n^2n}{2}$ is the number of edges. The vertices are labeled $1,2,3,\ldots n$.
Then follow $m$ lines each containing two spaceseparated integers $a$ and $b$ such that $1 \leq a,b \leq n$. They denote an edge between nodes $a$ and $b$.
Next, there are two spaceseparated integers $s$ and $t$, where $s$ is the number of your start node, and $t$ is the number of your goal node.
This is followed by a number $k$ where $1 \leq k \leq n$ indicating the number of flyering people, along with $k$ lines each containing one integer indicating the start node of each flyering person.
Output
Print YES if it is possible for the student to avoid the flyering people at every turn before reaching the goal node, and NO otherwise.
Sample Input 1  Sample Output 1 

3 2 1 2 2 3 2 3 1 1 
YES 
Sample Input 2  Sample Output 2 

3 3 1 2 2 3 1 3 2 3 1 1 
NO 