eolymp
bolt
Try our new interface for solving problems
Problems

Car race

Car race

In the city of N in the near future will take place the world championship car racing among the cars of Formula-0. As the organizers haven't the time to build a special race track for these competitions, it was decided to organize a track in the streets of the city. In the city of N there are $n$ intersections, some pairs of which are connected by roads, the movement which is possible in both directions. In this case, any two of the intersection are connected by no more than one way, and it is possible to reach by road from any intersection before anyone else. The route, where every competition will be held must be circular (i.e. should start and finish at the same intersection), while in the process of movement along it the crossing should occur no more than once. At the preliminary stage of preparation of the organizing committee was set up a list of all city roads. Now it's time to use it. The first question that must be addressed --- is the question of existence in the desired circular route (of course, if the answer is negative, the organizers will have to urgently build some more roads). The only problem is that the organizers have a suspicion that, since the list was compiled not too closely, it has some of the roads listed more than once. Write a program that, given the list of roads in the city, determine is it possible to organize the desired circular track. \InputFile The first line contains two integers: $n~(1 \le n \le 1000)$ --- the number of intersections in the city of N and $m~(0 \le m \le 10^5)$ --- the number of roads in the compiled list. Following $m$ lines describe the roads. Each road is given by two numbers: $u$ and $v~(1 \le u, v \le n, u \ne v)$ --- the numbers of intersections that it connects. Since the roads are bidirectional, the pair $(u, v)$ and a pair $(v, u)$ describes the same road. \OutputFile Print \textbf{YES}, if the city might organize a circular track for competition, and the word \textbf{NO} otherwise. \includegraphics{https://static.e-olymp.com/content/e1/e11b5a64a57c366943963d73cf519d8da3389ba7.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
3 4
1 2
2 3
3 1
3 2
Output example #1
YES
Input example #2
2 3
1 2
2 1
2 1
Output example #2
NO