import java.io.*; import java.util.*; public class ise { static double st[][]; static double wa[][]; static double dist[][]; static int num_store; static int num_ware; public static void main(String args[]) { try { Scanner sc = new Scanner(new File("ise.in")); int num_datasets = sc.nextInt(); for(int i = 0; i < num_datasets; i++) { num_store = sc.nextInt(); num_ware = sc.nextInt(); st = new double[num_store][2]; wa = new double[num_ware][3]; for(int j = 0; j < num_store; j++) { st[j][0] = sc.nextDouble(); st[j][1] = sc.nextDouble(); } for(int j = 0; j < num_ware; j++) { wa[j][0] = sc.nextDouble(); wa[j][1] = sc.nextDouble(); wa[j][2] = sc.nextDouble(); } System.out.println("Data Set "+(i+1)+":"); makeDist(); boolean mask[] = new boolean[num_ware]; double sol = search(mask,0,-1); System.out.println((new java.text.DecimalFormat("#.##")).format(sol)); } } catch(IOException e) { System.out.println(e); } } static void makeDist() { dist = new double[num_store][num_ware]; for(int i = 0; i < num_store; i++) { for(int j = 0; j < num_ware; j++) { double d_x = st[i][0] - wa[j][0]; double d_y = st[i][1] - wa[j][1]; dist[i][j] = Math.sqrt((d_x*d_x) + (d_y*d_y)); } } } static double search(boolean mask[], int index, double bound) { if(index < num_ware) { mask[index] = true; double s1 = search(mask, index+1, bound); if(s1 < bound) bound = s1; mask[index] = false; double s2 = search(mask, index+1, bound); if(s2 == -1 || s1 < s2) return s1; else return s2; } else { return score(mask, bound); } } static double score(boolean mask[], double bound) { double total = 0.0; for(int i = 0; i < num_store; i++){ double min = -1; for(int j = 0; j < num_ware; j++) { if(mask[j]) { if(min == -1 || dist[i][j] < min) min = dist[i][j]; } } if(min == -1) { return -1; } else { total += min; if(bound != -1 && total > bound) return -1; } } for(int j = 0; j < num_ware; j++) { if(mask[j]) { total += wa[j][2]; } } return total; } }