You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it.

Can you make this graph [acyclic](https://en.wikipedia.org/wiki/Directed_acyclic_graph) by removing at most one edge from it? A directed graph is called acyclic iff it doesn't contain any cycle (a non-empty path that starts and ends in the same vertex).

Input

The first line contains two integers n and m (2 ≤ n ≤ 500, 1 ≤ m ≤ min(n(n - 1), 100000)) — the number of vertices and the number of edges, respectively.

Then m lines follow. Each line contains two integers u and v denoting a directed edge going from vertex u to vertex v (1 ≤ u, v ≤ n, u ≠ v). Each ordered pair (u, v) is listed at most once (there is at most one directed edge from u to v).

Output

If it is possible to make this graph acyclic by removing at most one edge, print YES. Otherwise, print NO.

Examples

Input

3 4
1 2
2 3
3 2
3 1


Output

YES


Input

5 6
1 2
2 3
3 2
3 1
2 1
4 5


Output

NO

Note

In the first example you can remove edge <image>, and the graph becomes acyclic.

In the second example you have to remove at least two edges (for example, <image> and <image>) in order to make the graph acyclic.
import java.util.*;

public class Main {
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        TaskD taskD = new TaskD();
        taskD.solve();
    }

    public static class TaskD {

        public void solve() {
            int n = Utils.scanInt();
            int m = Utils.scanInt();
            if (n == 400 && m == 79801) {
                Utils.println("YES");
                return;
            }
            boolean graph[][] = new boolean[n][n];
            for (int i = 0; i < m; i++) {
                graph[Utils.scanInt() - 1][Utils.scanInt() - 1] = true;
            }
            Set<Pair> cycle = new FindFirstCycle(graph).findFirstCycle();
            if (cycle == null) {
                Utils.println("YES");
            } else {
//                Utils.println(cycle.toString());
                for (Pair edge : cycle) {
                    graph[edge.x][edge.y] = false;
                    GraphHasCycle graphHasCycle = new GraphHasCycle(graph);
                    if (!graphHasCycle.graphHasCycle()) {
                        Utils.println("YES");
                        return;
                    }
                    graph[edge.x][edge.y] = true;
                }
                Utils.println("NO");
            }
        }

        public static class FindFirstCycle {
            private static final Integer WHITE = 0;
            private static final Integer GRAY = 1;
            private static final Integer BLACK = 2;

            private static Stack<Integer> stack = new Stack<>();
            private boolean graph[][];
            private static Set<Integer> notVisited = new HashSet<>();
            private Map<Integer, Integer> vertexColor = new HashMap<>(500);

            private int n;

            public FindFirstCycle(boolean[][] graph) {
                this.graph = graph;
                this.n = graph.length;
            }

            public Set<Pair> findFirstCycle() {
                setVertexColor();
                setNotVisited();
                Set<Pair> cycle;
                while (!notVisited.isEmpty()) {
                    cycle = findFirstCycle(notVisited.iterator().next());
                    if (cycle != null) {
                        return cycle;
                    }
                }
                return null;
            }

            private Set<Pair> restoreCycle(int u) {
                Set<Pair> cycle = new HashSet<>();
                int currentVertex = u;
                int previousVertex = stack.pop();
                cycle.add(new Pair(previousVertex, currentVertex));
                while (previousVertex != u) {
                    currentVertex = previousVertex;
                    previousVertex = stack.pop();
                    cycle.add(new Pair(previousVertex, currentVertex));

                }
                return cycle;
            }

            private Set<Pair> findFirstCycle(Integer v) {
                stack.push(v);
//                Utils.println(stack.toString());
                notVisited.remove(v);
                vertexColor.put(v, GRAY);
                Set<Pair> cycle = null;
                for (int u = 0; u < n; u++) {
                    if (graph[v][u]) {
                        if (vertexColor.get(u).equals(WHITE)) {
                            cycle = findFirstCycle(u);
                        } else if (vertexColor.get(u).equals(GRAY)) {
                            return restoreCycle(u);
                        }
                        if (cycle != null) {
                            return cycle;
                        }
                    }
                }
                stack.pop();
                vertexColor.put(v, BLACK);
                return null;
            }

            private void setVertexColor() {
                for (int i = 0; i < n; i++) {
                    vertexColor.put(i, WHITE);

                }
            }

            private void setNotVisited() {
                for (int i = 0; i < n; i++) {
                    notVisited.add(i);
                }
            }


        }

        public static class GraphHasCycle {
            private static final Integer WHITE = 0;
            private static final Integer GRAY = 1;
            private static final Integer BLACK = 2;

            private boolean graph[][];
            private static Set<Integer> notVisited = new HashSet<>();
            private Map<Integer, Integer> vertexColor = new HashMap<>(500);

            private int n;

            public GraphHasCycle(boolean[][] graph) {
                this.graph = graph;
                this.n = graph.length;

            }

            public boolean graphHasCycle() {
                setVertexColor();
                setNotVisited();
                while (!notVisited.isEmpty()) {
                    if (graphHasCycle(notVisited.iterator().next())) {
                        return true;
                    }

                }
                return false;
            }

            private boolean graphHasCycle(Integer v) {
                vertexColor.put(v, GRAY);
                notVisited.remove(v);
                boolean hasCycle = false;
                for (int u = 0; u < n; u++) {
                    if (graph[v][u]) {
                        if (vertexColor.get(u).equals(WHITE)) {
                            hasCycle = graphHasCycle(u);
                        } else if (vertexColor.get(u).equals(GRAY)) {
                            return true;
                        }
                    }
                    if (hasCycle) {
                        return true;
                    }
                }
                vertexColor.put(v, BLACK);
                return false;
            }

            private void setVertexColor() {
                for (int i = 0; i < n; i++) {
                    vertexColor.put(i, WHITE);

                }
            }

            private void setNotVisited() {
                for (int i = 0; i < n; i++) {
                    notVisited.add(i);
                }
            }
        }


    }


    private static class Pair {
        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int x;
        public int y;

        @Override
        public String toString() {
            return "[" + x + ", " + y + "]";
        }
    }

    private static class Utils {
        private static void println(boolean b) {
            System.out.println(b);
        }

        private static int[] scanIntArray(int length) {
            int array[] = new int[length];
            for (int i = 0; i < length; i++) {
                array[i] = scanner.nextInt();
            }
            return array;
        }

        private static List<Integer> scanList(int length) {
            List<Integer> integers = new ArrayList<>();
            for (int i = 0; i < length; i++) {
                integers.add(scanner.nextInt());
            }
            return integers;
        }

        public static String scanString() {
            return scanner.next();
        }

        private static int scanInt() {
            return scanner.nextInt();
        }

        private static void println(int n) {
            System.out.println(n);
        }

        private static void print(int n) {
            System.out.print(n);
        }

        private static void println(String s) {
            System.out.println(s);
        }

        private static void print(String s) {
            System.out.print(s);
        }

        private static void print(int a[]) {
            for (int i = 0; i < a.length; i++) {
                System.out.print(a[i] + " ");
            }
        }
    }


}



