시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 256 MB 24 15 15 62.500%

## 문제

Lasse is organizing the orienteering world championship in Trondheim in 2008. Since he has been running in Bymarka for decades, he has a lot of route proposals. He must find a route with just the right length, but he doesn’t have time to measure them all by running through the control points in order, as he is too busy parallelizing code. The job is therefore given to Ola, who he thinks spends too much time with schoolwork.

As Ola is slightly less interested in orienteering, he figures out a more time-saving way of measuring the length of all the routes. He brings his GPS, visits all the points of all the routes in the most convenient order, and goes home early to do the rest of the job on his computer.

## 입력

The first line of input gives 1 ≤ n ≤ 1000, the total number of control points. Then follow n lines giving their coordinates, with two floating-point numbers xi and yi, with 0.0 ≤ xi, yi ≤ 10000.0. The number of routes is then given by 1 ≤ m ≤ 100. Each route is defined by first a line with 2 ≤ p ≤ 17, the number of control points (including start and goal), and then a line with p indexes 0 ≤ i < n, identifying them.

## 출력

For each test case output the total track distance, rounded, with no decimals.

## 예제 입력 1

5
0.0 0.0
1000.0 1000.0
123.45 0.0
3475.43 7765.4
4325.9865 13.0
2
2
0 1
4
3 1 4 0


## 예제 출력 1

1414
14999