// Arup Guha
// 9/23/2014
// Solution to 2005 World Finals Problem J: Zones

import java.util.*;

public class zones {

    public static void main(String[] args) {

        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
        int k = stdin.nextInt();
        int loop = 1;

        // Go through each case.
        while (n != 0) {

            // Read in full tower coverage.
            int[] coverage = new int[n];
            for (int i=0; i<n; i++)
                coverage[i] = stdin.nextInt();

            // Read in zones.
            HashMap<Integer,Integer> zones = new HashMap<Integer,Integer>();
            int numZones = stdin.nextInt();
            for (int i=0; i<numZones; i++) {

                // Store subset as its mask.
                int nTowers = stdin.nextInt();
                int mask = 0;
                for (int j=0; j<nTowers; j++)
                    mask += (1 << (stdin.nextInt()-1));
                zones.put(mask, stdin.nextInt());
            }

            // Will store final answers here.
            int best = 0, mask = 0;

            // i represents the subset we are trying.
            for (int i=0; i<(1<<n); i++) {

                // Only look at these.
                if (Integer.bitCount(i) == k) {

                    // Evaluate and store if better.
                    int curSum = eval(coverage, zones, i);
                    if (curSum > best || (curSum == best && beat(i, mask) ) ) {
                        best = curSum;
                        mask = i;
                    }
                }
            }

            // Output result.
            System.out.println("Case Number  "+loop);
            System.out.println("Number of Customers: "+best);
            System.out.print("Locations recommended: ");

            // Print subset.
            for (int i=0; i<n; i++)
                if (((mask >> i) & 1) == 1)
                    System.out.print((i+1)+" ");
            System.out.println("\n");

            // Get next case.
            n = stdin.nextInt();
            k = stdin.nextInt();
            loop++;
        }
    }

    public static int eval(int[] coverage, HashMap<Integer,Integer> zones, int mask) {

        // Initial sum.
        int total = 0;
        for (int i=0; i<coverage.length; i++)
            if (((mask >> i) & 1) == 1)
                total += coverage[i];

        // Sub out overlaps.
        for (Integer subset: zones.keySet()) {
            int overlaps = Integer.bitCount(subset & mask);
            if (overlaps > 0) total -= ((overlaps-1)*zones.get(subset));
        }

        return total;
    }
    
    // Returns true iff mask1 is lexicographically before mask2.
    public static boolean beat(int mask1, int mask2) {
    	
    	// Peel off bits from right.
    	while (true) {
    		int bit1 = mask1 & 1;
    		int bit2 = mask2 & 1;
    		
    		// Condition of unequal bits, so we can return.
    		if ((bit1 ^ bit2) == 1) return bit1 > bit2;
    		mask1 = mask1 >> 1;
    		mask2 = mask2 >> 1;
    	}
    }
}
