import java.io.*; import java.util.*; class classes { public classes(int utility, int [] meeting, int workl) { util = utility; meet = meeting; work = workl; } public void print() { for(int i =0 ;i < meet.length;i++) System.out.print(meet[i] + " "); System.out.println(); } public int util; public int [] meet; public int work; } public class courses { public static double MAX_UTIL = 0; public static void main(String [] args) throws Exception { BufferedReader in = new BufferedReader(new FileReader("courses.in")); String input = in.readLine(); int NUMBER_OF_SETS = Integer.parseInt(input); for(int i =0 ; i < NUMBER_OF_SETS;i++) { input = in.readLine(); StringTokenizer tok = new StringTokenizer(input); int NUM_CLASSES = Integer.parseInt(tok.nextToken()); int NUM_MEETING_SLOTS = Integer.parseInt(tok.nextToken()); int CAPACITY = Integer.parseInt(tok.nextToken()); classes [] classArray = new classes[NUM_CLASSES]; for(int j = 0; j < NUM_CLASSES; j++) { input = in.readLine(); tok = new StringTokenizer(input); int temp_util = Integer.parseInt(tok.nextToken()); int WORK_LOAD = Integer.parseInt(tok.nextToken()); int [] meets = new int[NUM_MEETING_SLOTS]; tok.nextToken(); for(int x = 0; x < NUM_MEETING_SLOTS; x++) meets[x] = 0; while(tok.hasMoreTokens()) { meets[Integer.parseInt(tok.nextToken())-1] = 1; } classArray[j] = new classes(temp_util,meets,WORK_LOAD); } int [] blank = new int[NUM_MEETING_SLOTS]; for(int x = 0; x < NUM_MEETING_SLOTS; x++) blank[x] = 0; if (i != 0) System.out.print("\n"); System.out.println("Data Set " + (i+1) + ":"); System.out.print((new java.text.DecimalFormat("#.##")).format(processArray(0,blank,0,classArray,NUM_CLASSES,CAPACITY))); } } public static int processArray(int currentWork, int [] currentMeets, int currentUtil, classes [] classArray, int NUM_CLASSES, int MAX_WORK) { int [] results = new int[NUM_CLASSES]; boolean try_one = false; for(int i = 0; i < NUM_CLASSES; i++) { if ((currentWork + classArray[i].work) < MAX_WORK) { boolean good = true; for(int j = 0; j < currentMeets.length; j++) if (classArray[i].meet[j] == 1 && currentMeets[j] == 1) good = false; if (good) { int [] newArray = new int[currentMeets.length]; for(int j = 0; j < currentMeets.length; j++) if (classArray[i].meet[j] == 1 || currentMeets[j] == 1) newArray[j] = 1; results[i] = processArray(currentWork + classArray[i].work, newArray, currentUtil + classArray[i].util, classArray, NUM_CLASSES, MAX_WORK); try_one = true; } } } if (!try_one) return currentUtil; int max = 0; for(int i = 0; i < NUM_CLASSES;i++) if (results[i] > max) max = results[i]; return max; } }