#include #include #include #include #include using namespace std; const int maxn = 111; int rudu[maxn]; vectorljb[maxn]; int main() { int n, m, u, v, ii,i; while (~scanf("%d%d", &n, &m)) { memset(rudu, 0, sizeof(rudu)); for (i = 0; i <= n; i++) ljb[i].clear(); for (i = 0; i < m; i++) { scanf("%d%d", &u, &v); ljb[v].push_back(u); rudu[u]++; } int tot = 0; while (1) { int flag = 0; for (ii = 1; ii <= n; ii++) { if (rudu[ii] == 0) { flag = 1; tot++; rudu[ii]--; for (i = 0; i < ljb[ii].size(); i++) { rudu[ljb[ii][i]]--; } break; } } if (!flag) break; } if (tot == n) printf("YES\n"); else printf("NO\n"); } return 0; }