#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin() , v.end()
#define sz(v) int(v.size())
#define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
using namespace std;
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<long long , int> lli;
const int maxN = int(2e5)+7;
int n , m , a[maxN];
vector<int> adj[maxN];
vector<int> topo;
bool vis[maxN];
int g[maxN];
void dfs_topo(int u){
vis[u] = 1;
for (int v : adj[u]){
if (vis[v] == 0){
dfs_topo(v);
}
}
topo.push_back(u);
}
void solve(){
cin >> n >> m;
for (int i = 1 ; i <= m ; i++){
int u , v;
cin >> u >> v;
adj[u].push_back(v);
}
for (int i = 1 ; i <= n ; i++) cin >> a[i];
for (int i = 1 ; i <= n ; i++){
if (vis[i] == 0) dfs_topo(i);
}
for (int u : topo){
vector<int> val;
for (int v : adj[u]) val.push_back(g[v]);
unq(val);
if (val.empty() == 0){
if (val[0] > 0) g[u] = 0;
else{
g[u] = val.back() + 1;
for (int i = 1 ; i < sz(val) ; i++){
if (val[i - 1] + 1 < val[i]) g[u] = min(g[u] , val[i - 1] + 1);
}
}
}
}
int x = 0;
for (int i = 1 ; i <= n ; i++) if (a[i]&1) x ^= g[i];
if (x) cout << "YES\n"; else cout << "NO\n";
}
#define name "A"
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen(name".INP" , "r")){
freopen(name".INP" , "r" , stdin);
freopen(name".OUT" , "w" , stdout);
}
int t = 1; //cin >> t;
while (t--) solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZmkgZmlyc3QKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBhbGwodikgdi5iZWdpbigpICwgdi5lbmQoKQojZGVmaW5lIHN6KHYpIGludCh2LnNpemUoKSkKI2RlZmluZSB1bnEodikgc29ydChhbGwodikpOyB2LnJlc2l6ZSh1bmlxdWUoYWxsKHYpKSAtIHYuYmVnaW4oKSk7CnVz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AwOwogICAgICAgICAgICBlbHNlewogICAgICAgICAgICAgICAgZ1t1XSA9IHZhbC5iYWNrKCkgKyAxOwogICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDEgOyBpIDwgc3oodmFsKSA7IGkrKyl7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbFtpIC0gMV0gKyAxIDwgdmFsW2ldKSBnW3VdID0gbWluKGdbdV0gLCB2YWxbaSAtIDFdICsgMSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBpbnQgeCA9IDA7CiAgICBmb3IgKGludCBpID0gMSA7IGkgPD0gbiA7IGkrKykgaWYgKGFbaV0mMSkgeCBePSBnW2ldOwogICAgaWYgKHgpIGNvdXQgPDwgIllFU1xuIjsgZWxzZSBjb3V0IDw8ICJOT1xuIjsKfQoKI2RlZmluZSBuYW1lICJBIgoKaW50IG1haW4oKXsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApOwogICAgaWYgKGZvcGVuKG5hbWUiLklOUCIgLCAiciIpKXsKICAgICAgICBmcmVvcGVuKG5hbWUiLklOUCIgLCAiciIgLCBzdGRpbik7CiAgICAgICAgZnJlb3BlbihuYW1lIi5PVVQiICwgInciICwgc3Rkb3V0KTsKICAgIH0KICAgIGludCB0ID0gMTsgLy9jaW4gPj4gdDsKICAgIHdoaWxlICh0LS0pIHNvbHZlKCk7CiAgICByZXR1cm4gMDsKfQoK