cho.sh
Notes
Loading...

Beyond the Walls

Time limit

2s

Memory limit

128 MB

Problem

A country has walls connecting villages. Villages are points, and each wall is a line segment connecting two villages. No two walls cross, and all walls form one connected structure. The walls divide the country into several regions. To move from one region to a neighboring region, a person must cross the wall between them once.

At most one club member lives in each village, and some villages may have no member. The members want to meet in one region outside the villages, without passing through any village. A member can leave their village into any region incident to that village without crossing a wall. After that, moving to another region costs one wall crossing for each wall crossed.

For a chosen meeting region, consider the sum of the numbers of wall crossings needed by all members to reach it. Write a program that finds the minimum possible sum and a region where that minimum can be achieved.

Input

The first line contains the number of regions M, including the outside region. 2 <= M <= 200.

The second line contains the number of villages N. Villages are numbered from 1 to N, and 2 <= N <= 250.

The third line contains the number of club members L. 1 <= L <= 30 and L <= N.

The fourth line contains L integers in increasing order: the village numbers where the members live.

Then 2M lines follow, two lines for each region in input order. For each region, the first line contains I, the number of villages on its boundary. The next line contains the I village numbers in boundary order. The last region, region M, is the outside region; only for this region, the boundary villages are given in counterclockwise order. For all other regions, they are given in clockwise order.

Region numbers are their input positions. The first listed region is region 1, and the outside region is region M.

Output

On the first line, print the minimum possible total number of wall crossings for all members.

On the second line, print the number of a region where this minimum can be achieved. If several regions are optimal, any one of them may be printed.