#include<stdio.h>
#include<string.h>
#include<iostream>//只存在一个连通分量
#include<string.h>
using namespace std;
#define N 11000
#define NN 110000
struct node {//链表实现
int v,next;
}bian[NN];
int sta[N];//数组模拟寨
int top,dfn[N],low[N],yong,visit[N],head[N],index,ans;
void addedge(int u,int v) {
bian[yong].v=v;
bian[yong].next=head[u];
head[u]=yong++;
}
int min(int a,int b) {
return a>b?b:a;
}
void tarjan(int u) {//tarjan算法
int i;
dfn[u]=low[u]=++index;
sta[++top]=u;
visit[u]=1;
for(i=head[u];i!=-1;i=bian[i].next) {
int v=bian[i].v;
if(!dfn[v]) {
tarjan(v);
low[u]=min(low[u],low[v]);
}
else
if(visit[v]==1)
low[u]=min(low[u],dfn[v]);
}
if(dfn[u]==low[u]) {
int t;
ans++;
do{
t=sta[top--];
visit[t]=2;
}while(t!=u);
}
}
int main() {
int n,m,i,j,k;
while(scanf("%d%d",&n,&m),n||m) {
memset(head,-1,sizeof(head));
memset(dfn,0,sizeof(dfn));
memset(low,0,sizeof(low));
memset(visit,0,sizeof(visit));
yong=0;
top=0;
memset(sta,0,sizeof(sta));
while(m--) {
scanf("%d%d",&i,&j);
addedge(i,j);
}
ans=0;
index=0;
for(i=1;i<=n;i++)
if(visit[i]!=2) {
tarjan(i);
if(ans>1)//如果有多个连通分量就直接退出
break;
}
if(ans>1)
printf("No
");
else
printf("Yes
");
}
return 0;
}