|
|||||||
|
Agents
Because of the latest mishaps of their agents, Central Intelligence Agency of Byteland resolved to improve their activity. So far the biggest trouble has been a preparation of safe meetings of agents. Your program has to help in solving this. For a given description of the net of roads in Byteland and the initial positions of two agents, it should answer if their safe meeting is possible. To consider a meeting safe the agents must hold to the following precautions:
TaskWrite a program that:
InputIn the first line of the text file AGE.IN, there are two integers n and m separated by a single space, where 1<=n<=250, 0<=m<=n*(n-1). In the second line there are two integers a1 and a2 separated by a single space, 1<=a1, a2<=n and a1<>a2, denoting respectively the starting positions of agents No 1 and No 2. In the m following lines there are pairs of natural numbers a and b separated by single spaces, 1<=a,b<=n and a<>b, denoting that there is a road from city a to city b. OutputThere should be exactly one line in the text file AGE.OUT and it should contain:
ExampleFor the input file AGE.IN:6 7 1 5 1 2 4 5 2 3 3 4 4 1 5 4 5 6the correct answer is the output file AGE.OUT 3 |