#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <iomanip>
#include <string>

using namespace std;

const int N = 100003;
int us[N];
vector<int> res;
vector<int> g[N];

void dfs(int v)
{
    res.push_back(v);
    us[v] = 1;
    for(auto to: g[v])
    {
        if(us[to] == 0)
        {
            dfs(to);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin>>n>>m;
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin>>a>>b;
        g[a].push_back(b);
    }
    dfs(1);

    for(int i = 1; i <= n; i++)
    {
        if(us[i] == 0)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"NO";
}