turns, he does the following steps:
is playing connect the dots! Because he has no friends, he has to play connect the dots with himself. first starts with 1 dot on his canvas. Every turn, for- First, choose a number .
- For every dot currently on the canvas (exclude new dots painted this turn), paint new dots.
- Connect all of the new dots and the chosen dot such that they form a cycle of length .
- Repeat steps 2-3.
used for each turn. Please help !
has sold these canvases for millions of dollars. He has made so much money that other people has started making counterfeit paintings! , determined to destroy his enemies, wants to see whether their paintings follow his painting process. Specifically, wants to know whether the painting is invalid, or if it is valid, theInput Specification
The first line will contain 2 integers , the number of dots and lines on the canvas, respectively. It is guaranteed that is larger than all .
The next lines contain 2 integers , indicating that dots and are connected. Any 2 dots and will not be connected more than once.
Output Specification
If the painting is valid, output integers on their on line. Otherwise, output baf
.
Subtasks
Subtask 1 [30%]
Subtask 2 [70%]
Sample Input
12 15
1 2
1 3
2 3
1 4
4 5
5 6
6 1
2 7
7 8
8 9
9 2
3 10
10 11
11 12
12 3
Sample Output
3
4
Explanation for Sample
The cycle created in the first turn is composed of nodes and has a length of . There are cycles ; ; ; created in the second turn, each with a length of .
Comments