Under construction

Still being built. Things may change

James's Birthday Party

Interview

Time limit3sMemory limit1024 MB

Summary
Given a friendship graph of up to 100 people, decide whether losing any single friend pair's contact would leave someone uninvited, which means checking for a bridge edge.
Level

Medium4 of 10

Topics
Graph, DFS
Solved
No attempts yet

Problem

James needs to find out whether he can invite all of his friends to his birthday party. He does not have to invite them all himself. His friends forward invitations to each other.

For example, James has three friends: Lucy, Sue, and Mark. James is friends with all three, but he does not have Mark's phone number, so he cannot invite Mark directly. Sue has Mark's number (and Mark has Sue's), so Sue can invite Mark to the party.

The question is this: if anyone loses one of the phone numbers they have for someone else, would it become impossible to invite everybody? In the example above, if Sue loses Mark's number (the edge shown by the red arrow in the figure), then not everybody can be invited. Assume that if Sue loses Mark's number, Mark also loses Sue's number. Determine whether James is at risk of someone missing the party if any pair of friends loses contact with each other.

Input

The input contains multiple test cases. Each test case starts with a line containing two integers pp and cc. Here pp is the number of people James wants to invite, including himself, and cc is the number of connections.

1≤p≤1001 \le p \le 100, 0≤c≤50000 \le c \le 5000

The next cc lines each contain two integers aa and bb (0≤a<p0 \le a < p, 0≤b<p0 \le b < p, a≠ba \neq b). This means friend aa has friend bb's phone number and the reverse is also true.

The input ends with a line containing two zeros.

Output

For each test case, print "Yes" if some pair of friends could lose each other's numbers so that not everybody can be invited. Otherwise, print "No".

Examples1

  1. Example 1

    Input
    2 1
    0 1
    4 4
    0 1
    1 2
    2 3
    3 0
    5 5
    0 1
    1 2
    0 3
    3 4
    3 1
    0 0
    
    Expected output
    Yes
    No
    Yes