eolymp
bolt
Try our new interface for solving problems
Problems

Games on graph

Games on graph

\textit{The enemy began to e2-e4.} \textit{I have reviewed it and gave up architecture} \textit{_______________________________________________} \textit{From the memoirs of the 20th world champion Fritz Rybkin} Upon arrival, immediately demanded Aahz organize a meeting of the bookmakers, in which he outlined his plan. - \textit{The main task} - Aahz began his presentation to the bookies - \textit{learn to use to make progress. We plan to launch many new forms of competition that - quite possibly - lead to the fact that there will be some play by the rules, invented not by us. So, you must be able to quickly figure out how these rules may be useful to us.} - \textit{Is it possible at least in general to explain how this is done?} - Followed by a question from the audience. - \textit{Here is an example of the problem and decided that we will be able to deal with the whole class games. Dan directed graph of a game for two players and the starting position in it. Recall that in the game on a graph the player can walk out of position to any position in which there is an edge from the current one. Players take turns, plays someone who can not make a move. Required to check whether it is true that in any game party always wins the first player.} \InputFile The input file contains a description of one or more tests. The first line of each test set of vertices \textbf{V} and the number of edges \textbf{E} (\textbf{1} ≤ \textbf{V} ≤ \textbf{100000}, \textbf{1} ≤ \textbf{E} ≤ \textbf{100000}), as well as the number of the initial position \textbf{a} (\textbf{1} ≤ \textbf{a} ≤ \textbf{V}). This is followed by \textbf{E} string - description of edges in the form \textbf{u_i} \textbf{v_i} (\textbf{1} ≤ \textbf{u_i}, \textbf{v_i} ≤ \textbf{V}), which means that the edge directed from vertex \textbf{u_i} to vertex \textbf{v_i}. File ends with three zeros. The sum of all \textbf{E} for all tests does not exceed \textbf{100000}, the number of tests in the file does not exceed \textbf{1000}. \OutputFile Follow the example format as closely as possible - checking is done automatically.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3 2 1
1 2
1 3
1 1 1
1 1
0 0 0
Output example #1
First player always wins in game 1.
Players can avoid first player winning in game 2.
Author Виталий Вальтман, Андрей Лопатин
Source SСS - 2011 Sevastopol 08/08/2011 d.2 1st League