#P43. [KBC003C] Flu 1
[KBC003C] Flu 1
Source
This problem is adapted from Long Long OJ. All rights reserved.
Problem Background
In the distant Kingdom of KingCoder, an outbreak of idiocy flu has occurred.
Problem Description
There are residents in the Kingdom of KingCoder, with pairs of mutual friendship relationships among them.
Everyone who falls ill will recover on the second morning and gain immunity. They will not be infected on the second noon and the second afternoon, but their immunity will disappear on the second night, making them susceptible to infection again.
Each afternoon, every friend of a person sick (then) will visit them. Those unlucky ones without immunity (then) will be infected with the virus and fall ill on the next noon.
Now the king has told you all the friendship pairs and the person who fell ill on the first noon. Your task is to find the ID of the day when the latest infection occur.
Input Format
The first line of input contains three positive integers .
Each of the next lines contains two positive integers .
One relation may occur multiple times, and the relations & may occur simultaneously.
Relations satisfying may occur, in which the sick person will visit himself/herself but recover on the second morning and gain immunity normally.
Output Format
Output a single line containing the ID of the day (noon) when the latest infection occur.
If the virus can spread infinitely, output .
Samples
5 6 2
1 2
2 5
5 4
3 4
1 3
1 4
3
Sample Explanation
| Day ID | Persons Sick (Afternoon) | Persons With Immunity (Afternoon) |
|---|---|---|