Making changes to the trac routes in such a city can easily cause unexpected sidee cts if you do not plan carefully ahead. The story goes that a prominent member of the city council once submitted a proposal to the council regarding extensive changes to how the tracc should be organized in the city center. The proposal did have the merit that it would be very easy to drive in to the central square, but it would unfortunately also be impossible to drive out again. The council member in question later went on to become minister of justice in the country under the parole that society should be harder on criminals - "it should be easy to go to jail, but divcult to get out again".
To avoid mistakes as the one above, the city planners need you to develop a tool that can help them discover any tracc problems in the planning stage. The planners need to be alerted of two different situations. The first situation is that a street exists in the city center from which you cannot reach the surrounding, circular, system of roads, i.e., you are trapped inside the city. The second situation is that a street exists in the city that cannot be reached from the surrounding system of roads, i.e., it is unreachable.
The following lines: One line for each street (no particular order required and the surrounding road system is included) consisting of a number of integers. First an integer giving the id number of the street. Second, the number of (other) streets that can be reached from this street. Third, a sequence of street id numbers indicating which streets can be reached from this street.
If no problems are found, i.e., you are not trapped in any street and every street is reachable, you should print a single line containing the text "NO PROBLEMS". If multiple streets cause you to get trapped - or are unreachable - you should list them in the same order they were entered in the input (within respective category).
입력 6 0 1 1 1 1 2 2 3 1 3 0 3 0 4 2 5 0 5 1 4 출력 TRAPPED 3 UNREACHABLE 4 UNREACHABLE 5 입력 2 1 1 0 0 1 1 출력 NO PROBLEMS
출처:The 2011 Nordic Collegiate Programming Contest problem G