CF555E Case of Computer Network
Description
Andrewid the Android is a galaxy-known detective. Now he is preparing a defense against a possible attack by hackers on a major computer network.
In this network are $ n $ vertices, some pairs of vertices are connected by $ m $ undirected channels. It is planned to transfer $ q $ important messages via this network, the $ i $ -th of which must be sent from vertex $ s_{i} $ to vertex $ d_{i} $ via one or more channels, perhaps through some intermediate vertices.
To protect against attacks a special algorithm was developed. Unfortunately it can be applied only to the network containing directed channels. Therefore, as new channels can't be created, it was decided for each of the existing undirected channels to enable them to transmit data only in one of the two directions.
Your task is to determine whether it is possible so to choose the direction for each channel so that each of the $ q $ messages could be successfully transmitted.
Input Format
N/A
Output Format
N/A
Explanation/Hint
In the first sample test you can assign directions, for example, as follows: $ 1→2 $ , $ 1→3 $ , $ 3→2 $ , $ 4→3 $ . Then the path for for the first message will be $ 1→3 $ , and for the second one — $ 4→3→2 $ .
In the third sample test you can assign directions, for example, as follows: $ 1→2 $ , $ 2→1 $ , $ 2→3 $ . Then the path for the first message will be $ 1→2→3 $ , and for the second one — $ 2→1 $ .