Book Club

No attempts yetTime limit2sMemory limit256 MB

Problem

The book club in Porto holds a book exchange every year. Each member brings one book they love, finds another book they like, and trades with its owner.

In the past only two members who liked each other's book could trade. If member B liked the book member A brought and A liked the book B brought, the two swapped. Many members went home with the book they walked in with.

Looking for cycles instead of pairs allows more trades. Suppose A likes only B's book, B likes only C's book, and C likes only A's book. These three pass their books around in one direction and everyone gets a new book. A cycle may be longer than 3.

You are given the number of members and the books each member likes. Write a program that decides whether the books can be handed out so that every member receives a new one. A member gives up their own book only when they receive a book they like. In other words, assign every member ii a distinct book p(i)p(i) such that member ii likes p(i)p(i).

Input

The first line contains the number of members NN and the number of declarations of interest MM, separated by a space.

Each of the next MM lines contains two integers AA and BB, meaning that member AA likes the book member BB brought. AA and BB are always different, because a member never likes the book they brought themselves. The same pair (A,B)(A, B) is never given twice.

Output

Print YES if the books can be handed out so that every member receives a new one, and NO otherwise.

Constraints

  • 2N100002 \le N \le 10\,000
  • 1M200001 \le M \le 20\,000
  • MN2NM \le N^2 - N
  • 0A,B<N0 \le A, B < N and ABA \ne B