#include using namespace std; const int N=2e4+5,M=5e4+5; int n,m,k,cnt,dis[N],c[N],d[N],d1[N],head[N]; bool vis[N]; struct edge{ int to,nxt; }e[M<<1]; void add(int u,int v){ e[++cnt]=(edge){v,head[u]}; head[u]=cnt; } void bfs(){ queue q; for(int i=head[1];i;i=e[i].nxt){ int v=e[i].to; q.push(v); } while(!q.empty()){ int p=q.front();q.pop(); for(int i=head[p];i;i=e[i].nxt){ int v=e[i].to; vis[v]=true; c[v]++; d1[v]=d[v],d[v]=p; } } } bool check(int x,int y){ if(c[x]==1){ if(c[y]==1){ if(d[y]!=x&&d[y]!=d[x]&&d[x]!=y) return true; return false; } else if(c[y]==2){ if(d[x]!=y){ if(d[y]!=x&&d[y]!=d[x]) return true; if(d1[y]!=x&&d1[y]!=d[x]) return true; return false; } return false; } else{ if(d[x]!=y) return true; return false; } } else if(c[x]==2){ if(c[y]==1){ if(d[y]!=x){ if(d[x]!=y&&d[x]!=d[y]) return true; if(d1[x]!=y&&d1[x]!=d[y]) return true; return false; } return false; } else if(c[y]==2){ if(d[y]!=x&&d[y]!=d[x]&&d[x]!=y) return true; if(d1[y]!=x&&d1[y]!=d[x]&&d[x]!=y) return true; if(d[y]!=x&&d[y]!=d1[x]&&d1[x]!=y) return true; if(d1[y]!=x&&d1[y]!=d1[x]&&d1[x]!=y) return true; return true; } else{ return true; } } else{ if(c[y]==1){ if(d[y]!=x) return true; return false; } else if(c[y]==2){ return true; } else return true; } } int main(){ // freopen("circle.in","r",stdin); // freopen("circle.out","w",stdout); scanf("%d%d",&n,&m); for(int i=1,x,y;i<=m;i++){ scanf("%d%d",&x,&y); add(x,y),add(y,x); } bfs(); for(int i=2;i<=n;i++){ if(!vis[i]) continue; for(int j=head[i];j;j=e[j].nxt){ int v=e[j].to; if(!vis[v]) continue; if(check(i,v)){ printf("YES"); return 0; } } } printf("NO"); return 0; }