#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define maxn 10010
int dfn[maxn];
int low[maxn];
vector<int>G[maxn];
int N,M;
int ins[maxn];
int index;
int cnt;
int belong[maxn], st[maxn];
int top;
void init()
{
for(int i=0;i<maxn;++i)
dfn[i] = low[i] = ins[i] = 0;
index=cnt=top=0;
}
void trijan(int u)
{
ins[u] = 1 ;
dfn[u] = low[u] = ++index;
st[top++] = u;
for(int i = 0 ; i < G[u].size() ; ++i)
{
int v = G[u][i];
if( !dfn[v] )
{
trijan(v);
low[u] = min(low[u],low[v]);
}
else if( ins[v] == 1 )
{
low[u] = min(low[u],dfn[v]);
}
}
if( dfn[u] == low[u] )
{
cnt++;
int v ;
do
{
v = st[--top];
ins[v] = 0;
belong[v] = cnt;
}while( v != u );
}
}
int main()
{
while(cin >> N >> M , N + M)
{
init();
for(int i = 0; i < maxn; ++i) G[i].clear();
for(int i = 0 ; i < M ; ++i)
{
int a, b ;
scanf("%d %d",&a,&b);
G[a].push_back(b);
}
for(int i = 1 ; i <= N ; ++i)
if(!dfn[i])
trijan(1);
if( cnt == 1 )printf("Yes\n");
else printf("No\n");
}
}