Street Racing#7198

Street Racing

1 second
64 megabytes
Easy

Organizational committee for the Azure Coast-99 cycling race approached the Saint-Tropez gendarmerie with a request to allow the race to proceed through the streets of the town, granting each participant some freedom in choosing their route to the finish. In response, the gendarmerie provided the committee with a plan. Intersections are marked as circles, numbered from to , and one-way streets are depicted by arrows. In this plan:

Some points are unavoidable on any path from start to finish, excluding the start and finish themselves.

Certain unavoidable points on the path from start to finish can divide the race plan into two independent subplans. Specifically:

Write a program to help the organizing committee analyze the provided plan.

Input

The number of rows equals the total number of race points, (n \leq 222). For each from to , the -th row lists the endpoint numbers of the arrows originating from the -th point.

Output

The first line should list, in order, the numbers of the start and finish points.

The second line should contain the number of points unavoidable on any path from start to finish, followed by the numbers of these points in ascending order.

The third line should contain the number of points by which the race plan can be divided into separate subplans, followed by the numbers of these points in ascending order.

Examples

Example 1

Loading
Loading