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