#include"stdio.h" #include"string.h" const int N=105; int n,m; int indegree[N],map[N][N]; int top_sort() { int i,l,k; for(k=0;k<n;k++) { for(i=0;i<n;i++) { if(indegree[i]) continue; indegree[i]--; for(l=0;l<n;l++) { if(map[i][l]) { indegree[l]--; } } break; } if(i==n) return 0; } return 1; } int main() { int a,b; while(scanf("%d%d",&n,&m)!=-1) { if(!n) break; memset(map,0,sizeof(map)); memset(indegree,0,sizeof(indegree)); while(m--) { scanf("%d%d",&a,&b); if(!map[a][b]) { map[a][b]=1; indegree[b]++; } } int ans=top_sort(); if(ans) printf("YES "); else printf("NO "); } return 0; }