really likes the organic compound xylene, also known as dimethylbenzene. He has received an organic molecule as a present, and would like to know if there exists a dimethylbenzene somewhere in it.
However, organic chemistry is a struggle for
, so he'll settle for knowing whether or not his molecule contains six carbons atoms arranged in a ring, or cycle. There may be multiple cycles in 's present, but he's only interested in finding out if there is at least one that is six atoms long., and has given you distinct pairs of the form , representing a bond between atoms and .
has numbered the carbon atoms in his present fromDoes his present contain at least one cycle of length six?
Input Specification
The first line of input will contain two space-separated integers and .
The next lines will contain two integers and , defining a bond.
Output Specification
YES
if the given molecule contains a cycle that is six carbon atoms long, NO
otherwise.
Sample Input 1
6 6
1 2
2 3
3 4
4 5
5 6
6 1
Sample Output 1
YES
Explanation for Sample 1
This is a ring of six carbons: .
Sample Input 2
3 3
1 2
2 3
3 1
Sample Output 2
NO
Explanation for Sample 2
Though this may be a cycle, it is only of length three.
Sample Input 3
2 1
1 2
Sample Output 3
NO
Explanation of Sample 3
This is not a cycle!
Sample Input 4
8 8
1 2
2 3
3 4
4 5
5 6
6 1
6 7
7 8
Sample Output 4
YES
Sample Input 5
8 9
1 2
2 3
3 4
4 5
5 6
6 1
6 7
7 8
8 1
Sample Output 5
YES
Comments
can there be lines in between the circles? what would this output: 6 7 1 2 2 3 3 4 4 5 5 6 6 1 1 4
I noticed that the ladderane structure is possible, but I'm confused on whether a ladderane contains a 'simple cycle' of length 6.
Example Case:
What is the proper answer? Do the AC submissions disagree over this?
aren't the carbon atoms supposed to be placed in increasing order?
1 2, 2 3, 3 5, 5 6, 6 4, and 4 1 gives a simple cycle of length 6.
Cycle means simple cycle)