By Paulo E. D. Pinto, UERJ- Universidade do Estado do Rio de Janeiro Brazil
We are in an African country, where a dangerous virus has just arrived in a big city. The country will have to take extreme measures so that it does not spread. The only way out will be to block roads that arrive in infected cities. But the country only has the money to block a single stretch of road. In this country there is always at least one way between two cities. The Sanitary Surveillance wants to find out if there is a stretch of road that, when blocked, separates the rest of the country from the infected area.
You will help by making a program to identify if there is such an excerpt and indicate the maximum number of cities that can be isolated from the virus. Note that there may be more than one road stretch between two cities.
The first input line is an integer T (1 ≤ T ≤ 100), the number of test cases. The description of T test cases is given next. The description of each test is made in several lines. The first line contains 3 integers: N (1 ≤ N ≤ 1000), the number of cities of the country, M (N-1 ≤ M ≤ 10000), the number of roads and C (1 ≤ C ≤ N), the number of the infected city. The next M lines contains 2 integers each, describing one road between two cities. The cities are numbered from 1 to N.
For each test case print the maximum number of cities that can be isolated by blocking a stretch of road. If there is not an excerpt with the characteristics searched for, answer 0.
|Input Sample||Output Sample|