2000/2001 ACM SOUTHERN CALIFORNIA REGIONAL
SCHOLASTIC PROGRAMMING CONTEST

Problem 6
Team Packing
file: teampack.cc

Every year Swamp County holds its regional collegiate programming contest. One part of running the programming contest is assigning teams to workstations. The organizers attempt to locate teams such that teams from the same school are not assigned workstations close to each other. In the past this has been an ad hoc process. Your team will develop an application to allow the organizers to compare their ad hoc workstation assignments with the best possible layout. Input to your program is a list of Cartesian coordinates of workstation locations (in integer feet) followed by one line per school giving the number of teams from the school and the school name. There will be a maximum of 14 workstations, and 4 teams per school. The last workstation will always be located at `0,0'. The dimensions of the largest possible workstation lab are 200 by 200 feet. Also, the number of teams will not exceed the number of workstations, and there will always be at least one school with at least two teams. The input file may contain more than one scenario; in this case, the scenarios will be separated by a line of ten dashes (see the sample input below).

Output from your program is the square of the minimum distance between any two teams from the same school after teams have been assigned workstations that maximize this distance. The output is one line containing the left-justified integer value that is the squared distance.



Sample Input

3,0 6,0 9,0
0,2 3,2 6,2 9,2
0,5 3,5 6,5 9,5 14,3 14,6 0,0
3 Bogy U
3 Gator State
1 Armadillo Tech
2 CFTBL City College
1 Moss Institute
3 SC Polytechnic
----------
100,100 0,100 100,0 0,0
2 HMC
1 BYU
1 UVM


Sample Output

34
20000