
ZOJ Problem Set  1186
According to the Automobile Collision Monitor (ACM), most fatal traffic accidents occur on twoway streets. In order to reduce the number of fatalities caused by traffic accidents, the mayor wants to convert as many streets as possible into oneway streets. You have been hired to perform this conversion, so that from each intersection, it is possible for a motorist to drive to all the other intersections following some route. You will be given a list of streets (all twoway) of the city. Each street connects two intersections, and does not go through an intersection. At most four streets meet at each intersection, and there is at most one street connecting any pair of intersections. It is possible for an intersection to be the end point of only one street. You may assume that it is possible for a motorist to drive from each destination to any other destination when every street is a twoway street.
The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks. The output format consists of N output blocks. There is a blank line between output blocks.
Output Note: There may be many possible direction assignments satisfying the requirements. Any such assignment is acceptable.
1 7 10
1 2 1 2 Source: East Central North America 1998 