// Arup Guha
// 3/31/06
// Solution for 2005 Finals Problem J: Zones
// Basic idea behind the solution is this: Iterate through all subsets of towers in the order they prescribe,
// using an iterative method. For each subset, you have to accurately calculate the number of users. Most of 
// the information is given to you, because you get the information about each distinct "region" in the Venn
// Diagram, EXCEPT for the number of people that can serviced by ONLY one tower. In the example, drawn, you
// are given the values 7, 3, 2, 5 and 6. You just have to determine for yourself that there are 5, 8, 15,
// 19 and 18 people respectively that can ONLY be serviced by Towers 1, 2, 3, 4 and 5, respectively.
// This can be determined by taking the given value of the total number of people serviced by a tower, and 
// then just subtracting out the number of people that are in any overlapping region including the original.
// For example, to determine that there are 8 people that are ONLY serviced by Tower 2, you take the total 20,
// from that you subtract 7 people that belong to Towers 1 and 2, 2 people that belong to Towers 2 and 3, and 
// 3 people that belong to Towers 1, 2 and 3. Then, the solution is straight-forward. Update your best 
// combination ONLY when you BEAT a previous value outright.

import java.io.*;
import java.util.*;

public class zones {

  // Used to store information about all the intersections.
  public int[] groups;
  public int numpeople;

  public zones(int n) {
    groups = new int[n];
  }

  public static void main(String[] args) throws IOException {


    Scanner fin = new Scanner(new File("zones.in"));

    int n = fin.nextInt();
    int k = fin.nextInt();
    int casenum = 1;

    // loop till the sentinel data case.
    while (n != 0 && k != 0) {

      // Read in all the input data for this case.
      int[] towers = new int[n];
      for (int i=0; i<n; i++)
        towers[i] = fin.nextInt();

      int numinter = fin.nextInt();
      zones[] inter = new zones[numinter];

      for (int i=0; i<numinter; i++) {

        int size = fin.nextInt();
        inter[i] = new zones(size);
        for (int j=0; j<size; j++)
          inter[i].groups[j] = fin.nextInt();

        inter[i].numpeople = fin.nextInt();
        
      }

      // Adjust towers here just to store what's in each set and nothing else.
      // Basically, each time a tower number appears on an intersection list, we need 
      // subtract out the number of people in that intersection from the number of
      // people currently stored for that tower.
      for (int i=0; i<inter.length; i++) 
        for (int j=0; j<inter[i].groups.length; j++)
          towers[inter[i].groups[j]-1] -= inter[i].numpeople;
   
      

      System.out.println("Case Number  "+casenum);

      // This is the FIRST subset to check.
      int[] subset = new int[n];
      for (int i=0; i<k; i++)
        subset[i] = 1;
      for (int i=k; i<n; i++)
        subset[i] = 0;

   
      // These will store the most people and the set of towers to achieve that, respectively.
      int curmax = 0;
      int[] winset=null;
      
      // Loop through all possible subsets.
      for (int i=0; i<choose(n,k); i++) {

        int tempval=0;

        // First add in all the people serviced by one tower ONLY of the current subset.
        for (int j=0; j<n; j++)
          if (subset[j] == 1)
            tempval += towers[j];

        // We want to add in the number of people in each intersection if at least one of the
        // towers in the intersection is in our subset. We break because we don't want to add in
        // this value more than once!
        for (int j=0; j<numinter; j++) {          
          for (int z=0; z<inter[j].groups.length; z++)
            if (subset[inter[j].groups[z]-1] == 1) {
              tempval = tempval + inter[j].numpeople;
              break;
            }
        }
        
		// Update the max if necessary.
        if (tempval > curmax) {
          curmax = tempval;
          winset = getCopy(subset);
        }

		// Go to the next subset unless we're at the end.
        if (i < choose(n,k) - 1)
          nextSubset(subset);
        
      }

      // Output all the necessary data.
      System.out.println("Number of Customers: "+curmax);
      System.out.print("Locations recommended: ");
      for (int i=0; i<n; i++)
        if (winset[i] == 1)
          System.out.print((i+1)+" ");
      System.out.println("\n");

      // Read in the next case.
      n = fin.nextInt();
      k = fin.nextInt();
      casenum++;
    }

  }

  // Return a real copy of vals.
  public static int[] getCopy(int[] vals) {

    int[] retval = new int[vals.length];
    for (int i=0; i<vals.length; i++)
      retval[i] = vals[i];
    return retval;
  }

  // This changes subset so it stores the next lexicographical subset according to their definition.
  public static void nextSubset(int[] subset) {

    // Easy case, just "increment" the last one in the group.
    if (subset[subset.length-1] == 0) {

      int i = subset.length-1;
      while (subset[i] == 0)
        i--;

      subset[i+1] = 1;
      subset[i] = 0;

    }

    // This is the "wrap-over" case.
    else {

      int i = subset.length-1;
      int cnt = 0;

      // Go backwards through the one's representing towers in the subset.
      while (subset[i] == 1) {
        i--;
        cnt++;
      }

      // Now go backwards through the zero's representing towers not in the subset.
      while (subset[i] == 0)
        i--;

      // When we get here, this IS a tower in the old subset. We don't want it in the new one.
      subset[i] = 0;

      // We DO want this tower in our new subset.
      subset[i+1] = 1;
      i=i+2;
      
      // We want all of these towers in our subset.
      while (cnt > 0) {
        subset[i] = 1;
        i++;
        cnt--;
      }

      // And we don't want the rest.
      while (i < subset.length)
        subset[i++] = 0;

    }

    
  }

  // Determines a combo. There's no problem with int division due to the order in which things are done.
  public static int choose(int n, int k) {

    int start=1;
    for (int i=1; i<=k; i++) 
      start = start*(n+1-i)/i;
    return start;
  }

  // For debugging.
  public static void printSub(int[] sub) {
    for (int i=0;i<sub.length; i++)
      System.out.print(sub[i]+" ");
    System.out.println();
  }
}