C++#include <bits/stdc++.h>
using namespace std;
#define ll long long
int read() {
int s = 0, w = 1;
char ch = getchar();
while (ch > '9' || ch < '0') {
if (ch == '-')w = -w;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
s = (s << 1) + (s << 3) + ch - '0';
ch = getchar();
}
return s * w;
}
const int N = 5e3+3;
int n, m, k, s, x[N], y[N], rd[N];
int now;
int tot, to[N], hd[N], nxt[N];
bool vis[N][N], p[N], ans;
void add(int u, int v) {
to[++tot] = v;
nxt[tot] = hd[u];
hd[u] = tot;
}
int main() {
// freopen("cover.in","r",stdin);
// freopen("cover.out","w",stdout);
n = read(), m = read();
for (int i = 1; i <= m; i++) {
x[i] = read(), y[i] = read();
add(x[i], y[i]);
rd[y[i]]++;
}
k = read();
for (int i = 1; i <= k; i++)s = read(), p[s] = 1;
queue<int>q;
for (int i = 1; i <= n; i++)if (!rd[i])q.push(i);
while (!q.empty()) {
now = q.front(), q.pop();
// cout<<now<<' '<<'\n';
for (int i = hd[now]; i; i = nxt[i]) {
if (vis[i][to[i]])continue;
vis[i][to[i]] = true;
rd[to[i]]--;
// if (!rd[to[i]]) {
// if (p[i])
// q.push({to[i], now.second + 1});
// else
q.push(to[i]);
// }
}
}
for(int i=2;i<=s;i++)
for(int j=1;j<i;j++)
if((!vis[x[i]][y[j]]&&!vis[y[j]][x[i]])||(!vis[x[j]][y[i]]&&!vis[y[i]][x[j]])){
cout<<"NO";
return 0;
}
cout << "YES";
return 0;
}