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

public class fund_petr implements Runnable {
    final String TASK_ID = "fund";
    final String IN_FILE = TASK_ID + ".in";
    final String OUT_FILE = TASK_ID + ".out";

    public static void main(String[] args) {
        Locale.setDefault(Locale.US);
        new Thread(new fund_petr()).start();
    }

    public void run() {
        try {
            readInput();
            solve();
            writeOutput();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(57);
        }
    }

    class Desc {
        long money;
        List<Integer> prev;
        String command;

        public Desc(long money, List<Integer> prev, String command) {
            this.money = money;
            this.prev = prev;
            this.command = command;
        }
    }

    List<List<Integer>> states;
    Map<List<Integer>, Integer> stateMap;
    int[][] jumpBuy;
    int[][] jumpSell;
    int ns;
    int[] stateSum;

    long[][] best;
    short[][] prev;
    short[][] by;

    void buildStates() {
        stateMap = new HashMap<List<Integer>, Integer>();
        states = new ArrayList<List<Integer>>();
        List<Integer> l = new ArrayList<Integer>();
        rec(l, 0);
        ns = states.size();
        stateSum = new int[ns];
        jumpBuy = new int[ns][n];
        jumpSell = new int[ns][n];
        for (int i = 0; i < ns; ++i) {
            for (int x : states.get(i))
                stateSum[i] += x;
            for (int j = 0; j < n; ++j) {
                List<Integer> ll = new ArrayList<Integer>(states.get(i));
                ll.set(j, ll.get(j) + 1);
                Integer dest = stateMap.get(ll);
                if (dest != null)
                    jumpBuy[i][j] = dest;
                else
                    jumpBuy[i][j] = -1;
                ll.set(j, ll.get(j) - 2);
                dest = stateMap.get(ll);
                if (dest != null)
                    jumpSell[i][j] = dest;
                else
                    jumpSell[i][j] = -1;
            }
        }
    }

    private void rec(List<Integer> l, int sum) {
        if (l.size() >= n) {
            List<Integer> ll = new ArrayList<Integer>(l);
            states.add(ll);
            stateMap.put(ll, states.size() - 1);
            return;
        }
        for (int i = 0; i <= Math.min(kTotal - sum, k[l.size()]); ++i) {
            l.add(i);
            rec(l, sum + i);
            l.remove(l.size() - 1);
        }
    }

    private void solve() {
        buildStates();
        best = new long[m + 1][ns];
        for (int i = 0; i < ns; ++i)
            for (int j = 0; j <= m; ++j)
                best[j][i] = -1;
        prev = new short[m + 1][ns];
        by = new short[m + 1][ns];
        best[0][0] = c;
        for (int i = 0; i < m; ++i) {
            for (int cs = 0; cs < ns; ++cs) if (best[i][cs] >= 0) {
                long cb = best[i][cs];
                int sum = stateSum[cs];
                {
                    if (best[i + 1][cs] >= cb || sum > (m - i - 1)) {
                    } else {
                        best[i + 1][cs] = cb;
                        prev[i + 1][cs] = (short) cs;
                        by[i + 1][cs] = 0;
                    }
                }
                for (int j = 0; j < n; ++j) {
                    int nxt = jumpBuy[cs][j];
                    long nb = cb - cost[j][i];
                    if (nxt >= 0 && nb >= 0 && best[i + 1][nxt] < nb && sum + 1 <= (m - i - 1)) {
                        best[i + 1][nxt] = nb;
                        prev[i + 1][nxt] = (short) cs;
                        by[i + 1][nxt] = (short) (j + 1);
                    }
                    nxt = jumpSell[cs][j];
                    nb = cb + cost[j][i];
                    if (nxt >= 0 && best[i + 1][nxt] < nb) {
                        best[i + 1][nxt] = nb;
                        prev[i + 1][nxt] = (short) cs;
                        by[i + 1][nxt] = (short) (-(j + 1));
                    }
                }
            }
        }
    }

    PrintWriter writer;

    private void writeOutput() throws FileNotFoundException {
        writer = new PrintWriter(OUT_FILE);

        writer.printf("%.2f\n", ((double) best[m][0] / 100));
        bt(m, 0);

        writer.close();
    }

    private void bt(int time, int state) {
        if (time == 0)
            return;
        bt(time - 1, prev[time][state]);
        int m = by[time][state];
        if (m == 0)
            writer.println("HOLD");
        else if (m > 0)
            writer.println("BUY " + name[m - 1]);
        else
            writer.println("SELL " + name[-m - 1]);
    }

    long c;
    int m;
    int n;
    int kTotal;
    String[] name;
    int[] k;
    long[][] cost;

    private void readInput() throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = null;

        c = nextDouble();
        m = nextInt();
        n = nextInt();
        kTotal = nextInt();
        name = new String[n];
        k = new int[n];
        cost = new long[n][m];
        for (int i = 0; i < n; ++i) {
            name[i] = nextToken();
            int s = nextInt();
            k[i] = nextInt();
            for (int j = 0; j < m; ++j)
                cost[i][j] = nextDouble() * s;
        }
    }

    StringTokenizer tokenizer;
    BufferedReader reader;

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    long nextDouble() throws IOException {
        return Math.round(Double.parseDouble(nextToken()) * 100);
    }

}
