Coronavirus Outbreak

0

0 votes
Problem

There are N cities in a country, out of which M pairs of cities have been infected by coronavirus. Let C-D denote a pair of infected cities, having a direct path between them. For every three distinct cities (C, D, E), if C-D and D-E are infected pair of cities, having direct paths between them, then if C-E also has a direct path, the country will be set on HIGH ALERT.  

Print "YES", if the country is set on HIGH ALERT, otherwise print "NO".

Input

The first line of the input contains two integers N and M  — the number of cities and the number of pairs of cities that are infected by coronavirus.

The next M lines contain two distinct integers Ci and D. Cities Ci and Di have a direct path between them. No pair of cities will appear more than once in the input.

Constraints

3 ≤ ≤ 150000

0 ≤ M ≤ min(150000, (N*(N-1))/2)

1 ≤ C, Di ≤ N, Ci ≠ Di

Output

Print a single line containing "YES" or "NO".

 

Time Limit: 0.6
Memory Limit: 256
Source Limit:
Editor Image

?