#P3097. The Partition of A Graph

The Partition of A Graph

Problem Description

Simple enough, you’ll be given a simple undirected graph with n vertexes and m edges, try to divide this graph fits the following requirements: All edges are divided into several groups; only two edges exist in every group, and this two edges have common vertex.
Your task is to figure out if such a partition exists.

Input

There are multiple test cases, for each test case:
The first line contains two integers n (0<n<=1000) and m represent the number of vertexes and edges.
The following m lines, each line contains two integers represent two endpoints of an edge.
The vertexes are numbered from 1 to n.
The input terminated when n=m=0.

Output

For each test case, output one line, if such a partition exists, print “Yes”, otherwise, print “No”.

3 3 1 2 1 3 2 3 3 2 1 2 1 3 0 0
No Yes