| Ural Championship 2017 |
|---|
| Finished |
Let's define a figure as an "apple" if it can be represented as a combination of a single closed polygonal line and a single open polygonal line, both originating from the same vertex, without self-intersections. The closed line must have at least $$$3$$$ vertices, while the open line must have at least $$$2$$$ vertices, and they must not share any points other than the starting vertex.
Given the number of vertices and a set of segments connecting these vertices, determine if it is possible to arrange the vertices of the polygonal lines in the plane such that they form the "apple" figure.
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 100$$$) — the number of vertices and the number of connections between them, respectively. Each of the next $$$m$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \leq a_i \lt b_i \leq n$$$, $$$i = 1, 2, \ldots, m$$$) indicating that the vertices $$$a_i$$$ and $$$b_i$$$ are connected by $$$i$$$-th segment. Each pair of vertices is connected by at most one segment.
If the given figure can be classified as an "apple", output "Yes"; otherwise, output "No".
9 9 1 2 2 3 3 5 5 6 4 6 4 7 1 7 7 9 8 9
Yes
5 5 1 2 2 3 1 3 1 4 1 5
No
4 4 1 2 2 3 1 3 1 4
Yes
5 4 1 2 2 3 1 3 1 4
No
| Name |
|---|


