시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 0 0 0 0.000%

문제

A far away developing country is trying to improve its communication infrastructure. Currently, each city in the country has its local computer network, but there is no fast communication between the cities. The Autonomous Communications Ministry (ACM) of the country decided to create a fast, optical fiber network connecting every city. In order to do this, they decided to take the following approach. Pairs of cities were chosen to have an optical fiber link installed between them. The choice was such that there will be only one fiber path between any pair of cities, in order to reduce the cost. The pairs of cities were chosen considering many factors, including analysis of estimated demand and distance between the cities.

Each city will have one optical router installed, which will be used to connect all the optical links with one end in that city. In each city, there are many different locations where the optical router can be installed. Your task, as an engineer working on this project, is to develop a computer program to pick up the locations in each city in order to minimize the total length of fiber that will be necessary for this project.

입력

The input consists of multiple test cases. Each test case starts with a line containing the number of cities N (1 ≤ N ≤ 1000) in the country. Following, for each city, there is a sequence of lines. The first line contains the (unique) name of the city (only capital letters, at most 15), and the number of candidate sites Ci (1 ≤ Ci ≤ 50) where the optical router can be installed. Then, there is one line per candidate site, containing two integers X and Y representing the coordinates of the site (−10000 ≤ X, Y ≤ 10000). You should use the euclidean distance between the sites to compute the corresponding fiber length necessary to connect them. After the description of each city with its candidate sites, there are N − 1 lines, each containing the names of two cities that will have a fiber link installed between them. The end of the input is indicated by N = 0.

출력

For each test case, your program should print a line with the minimum total length of optical fiber to connect the requested cities. Your answer should be rounded to one decimal digit.

예제 입력

3
AUSTIN 1
500 500
DALLAS 2
1000 10
990 -10
ELPASO 2
0 0
30 0
ELPASO AUSTIN
DALLAS ELPASO
3
HUSTON 3
100 0
100 50
100 100
AUSTIN 2
200 0
180 40
SANANTONIO 2
0 -10
10 -50
HUSTON AUSTIN
HUSTON SANANTONIO
0

예제 출력

1646.3
189.9

힌트