Under construction

Still being built. Things may change

Impromptu Trip (Easy)

Interview

Time limit2sMemory limit1024 MB

Summary
Given a directed graph of countries and flights, check whether every country can reach all the others.
Level

Easy3 of 10

Topics
Graph, BFS, DFS
Solved
No attempts yet

Problem

Cheolmin decided to take an impromptu trip across NN countries to celebrate the end of the semester.

According to Cheolmin's research, there are MM flights in total among the NN countries. Each flight has a fixed departure country and arrival country.

Because this is an impromptu trip, Cheolmin will not plan the route in advance. Instead, he made the following plan.

  • First, choose a country to start the trip and go there.
  • After that, from the current country, take any flight of your choice that departs from it.
  • Cheolmin may visit the same country many times, and he may use the same flight many times.

Looking at this plan, you started to worry whether Cheolmin could visit all NN countries. So you decided to check in advance whether he can visit all countries no matter which starting point he chooses.

Input

The first line contains the number of countries NN and the number of flights MM. (1≤N≤200 0001 \le N \le 200\,000, 0≤M≤500 0000 \le M \le 500\,000)

From the second line onward, the MM lines each contain two integers vv and ww. This means there is a flight that departs from country vv and arrives at country ww. (1≤v,w≤N1 \le v, w \le N, v≠wv \ne w)

Output

Print Yes if, for any starting country, there is a route that visits all NN countries. Otherwise, print No.

Examples3

  1. Example 1

    Input
    4 5
    1 2
    2 3
    3 1
    1 4
    4 1
    
    Expected output
    Yes
    
  2. Example 2

    Input
    4 4
    1 2
    2 3
    3 4
    4 2
    
    Expected output
    No
    
  3. Example 3

    Input
    4 4
    1 2
    2 1
    3 4
    4 3
    
    Expected output
    No