/*--------------------------------------------------------------*/
/* ACM ICPC 2007-2008                                           */
/* Northeastern European Regional Contest                       */
/* St Petersburg - Barnaul - Tashkent - Batumi, November 28, 200*/
/*--------------------------------------------------------------*/
/* Problem F. Fund Management                                   */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Georgiy Korneev                        */
/*--------------------------------------------------------------*/
 
import java.io.*;
import java.util.*;

public class fund_gk {
    static Scanner in;
    static PrintWriter out;

    long c;
    int m;
    int n;
    int k;

    class Stock {
        String name;
        int count;
        long[] price = new long[m];

        Stock(Scanner in) {
            name = in.next();
            long size = in.nextInt();
            count = in.nextInt();

            for (int i = 0; i < m; i++) {
                price[i] = Math.round(in.nextDouble() * 100) * size;
            }
        }
    }

    Stock[] stocks;

    List<Transition[]> transitions = new ArrayList<Transition[]>();
    Map<Integer, Integer> codes = new HashMap<Integer, Integer>();
    int lastCode = 0;

    int encode(int[] count) {
        int q = 0;
        for (int i = 0; i < n; i++) {
            q = q * (k + 1) + count[i];
        }
        if (!codes.containsKey(q)) {
            codes.put(q, lastCode++);
        }
        return codes.get(q);
    }

    class Transition {
        final int from;
        final int to;
        final int buy;
        final int sell;

        Transition(int from, int to, int buy, int sell) {
            this.from = from;
            this.to = to;
            this.buy = buy;
            this.sell = sell;
        }

        long cost(int day) {
            return 
                ((buy >= 0) ? stocks[buy].price[day] : 0) + 
                ((sell >= 0) ? -stocks[sell].price[day] : 0);
        }

        @Override
        public String toString() {
            if (buy >= 0) return "BUY " + stocks[buy].name;
            if (sell >= 0) return "SELL " + stocks[sell].name;
            return "HOLD";
        }
    }

    int generate(int[] count, int c) {
        int code = encode(count);
        if (transitions.size() == code) {
            List<Transition> transitions = new ArrayList<Transition>();
            this.transitions.add(null);

            transitions.add(new Transition(code, code, -1, -1));
            
            for (int i = 0; i < n; i++) {
                if (count[i] < stocks[i].count && c < k) {
                    count[i]++;
                    transitions.add(new Transition(code, generate(count, c + 1), i, -1));
                    count[i]--;
                }
                if (count[i] > 0) {
                    count[i]--;
                    transitions.add(new Transition(code, generate(count, c - 1), -1, i));
                    count[i]++;
                }
            }
            this.transitions.set(code, transitions.toArray(new Transition[transitions.size()]));
            //System.out.println(Arrays.toString(count) + " " + transitions.size());
        }
        return code;
    }

    long[][] max;

    void run() {
        c = Math.round(in.nextDouble() * 100);
        m = in.nextInt();
        n = in.nextInt();
        k = in.nextInt();

        stocks = new Stock[n];
        for (int i = 0; i < n; i++) {
            stocks[i] = new Stock(in);
        }

        int root = generate(new int[n], 0);

        max = new long[m + 1][lastCode];
        Arrays.fill(max[0], -1);
        max[0][root] = c;

        Transition[][] by = new Transition[m + 1][lastCode];

        System.out.println(lastCode);

        for (int i = 0; i < m; i++) {
            long[] current = max[i];
            long[] next = max[i + 1];
            Arrays.fill(next, -1);
            for (int j = 0; j < lastCode; j++) {
                if (current[j] >= 0) {
                    for (Transition transition : transitions.get(j)) {
                        int to = transition.to;
                        long cost = current[j] - transition.cost(i);
                        if (next[to] < cost) {
                            next[to] = cost;
                            by[i + 1][to] = transition;
                        }
                    }
                }
            }                              
        }
        out.format("%.2f\n", max[m][root] / 100.0);

        List<Transition> actions = new LinkedList<Transition>();
        int j = root;
        for (int i = m; i > 0; i--) {
            actions.add(0, by[i][j]);
            j = by[i][j].from;
        }
        for (Transition t : actions) {
            out.println(t);
        }
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
        
        in = new Scanner(new File("input.txt"));
        out = new PrintWriter("output.txt");

//        while (in.hasNext()) {
            new fund_gk().run();
//        }

        out.close();
        in.close();
    }
}
