A release tool publishes a proposed build order: a permutation of all n modules. A directed edge u v means module u must be built before module v. The proposed order is valid if and only if, for every edge u v, module u appears earlier than module v in the order. Decide whether the proposed order is valid.
Input format
Line 1: two integers n and — the number of nodes (labeled through ) and the number of directed edges.
Each of the next lines: two integers , a directed edge from to (read as: must come before ).
The final line: space-separated integers, a permutation of giving the proposed build order (first built to last built).
Output format
Print YES if the proposed order satisfies every edge, otherwise NO.
Constraints
- 1 <= n <= 100000
- 0 <= m <= 200000
- 0 <= u, v <= n-1 (a self-loop
u ucan never be satisfied) - The final line is guaranteed to be a permutation of
0..n-1.