/*--------------------------------------------------------------*/
/* ACM ICPC 2007-2008                                           */
/* Northeastern European Regional Contest                       */
/* St Petersburg - Barnaul - Tashkent - Batumi, November 28, 200*/
/*--------------------------------------------------------------*/
/* Problem F. Fund Management                                   */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Roman Elizarov                         */
/*--------------------------------------------------------------*/
 
/*
    Solution for NEERC'2007 Problem F: Fund Manageent
    (C) Roman Elizarov
    Note: this solution attempts to check correctness of the input
*/

import java.io.*;
import java.util.*;

public class fund_re {
	private static final long MAX_PORTFOLIO_COST = 8 * 99999 * 1000000L + 1;

	public static void main(String[] args) throws Exception {
		new fund_re().go();
	}

	private static long getCash(double cd) {
		long c = (long) (cd * 100 + 1e-5);
		assert cd == c / 100.0 : cd;
		assert c >= 1 && c <= 10000000000L : cd;
		return c;
	}

	private static int getPrice(double pd) {
		int p = (int) (pd * 100 + 1e-5);
		assert pd == p / 100.0 : pd;
		assert p >= 1 && p <= 99999 : pd;
		return p;
	}

	private static class Pos {
		final int t;
		final int[] pos;

		Pos(int t, int[] pos) {
			this.t = t;
			this.pos = pos.clone();
		}

		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;
			Pos pos1 = (Pos) o;
			if (!Arrays.equals(pos, pos1.pos)) return false;
			return true;
		}

		public int hashCode() {
			return Arrays.hashCode(pos);
		}
	}

	long c0;
	int m; // days
	int n; // stocks
	int k; // limit

	String[] name;
	int[] si;
	int[] ki;
	long[][] p;

	int poscnt;
	final ArrayList<Pos> poslist = new ArrayList<Pos>();
	final HashMap<Pos, Integer> posmap = new HashMap<Pos, Integer>();

	int[][] buy;
	int[][] sell;

	long[][] cc;
	int[][] prev;

	void go() throws Exception {
		XScanner in = new XScanner(new File("fund.in"));
		in.useLocale(Locale.US);
		c0 = getCash(in.nextDouble());
		m = in.nextInt();
		n = in.nextInt();
		k = in.nextInt();
		in.nextLine();

		assert m >= 1 && m <= 100;
		assert n >= 1 && n <= 8;
		assert k >= 1 && k <= 8;

		name = new String[n];
		si = new int[n];
		ki = new int[n];
		p = new long[n][m];

		for (int i = 0; i < n; i++) {
			name[i] = in.next();
			si[i] = in.nextInt();
			ki[i] = in.nextInt();
			in.nextLine();

			assert name[i].length() >= 1 && name[i].length() <= 5;
			for (int j = 0; j < name[i].length(); j++)
				assert name[i].charAt(j) >= 'A' && name[i].charAt(j) <= 'Z';
			for (int j = 0; j < i; j++)
				assert !name[i].equals(name[j]);
			assert si[i] >= 1 && si[i] <= 1000000;
			assert ki[i] >= 1 && ki[i] <= k;

			for (int t = 0; t < m; t++) {
				p[i][t] = getPrice(in.nextDouble());
			}
			in.nextLine();
		}
		in.close();

		// renumber positions
		numPos(0, 0, new int[n]);

		// precompute actions
		buy = new int[poscnt][n];
		sell = new int[poscnt][n];
		for (int q = 0; q < poscnt; q++) {
			for (int i = 0; i < n; i++) {
				Pos pos = poslist.get(q);
				if (pos.pos[i] < ki[i] && pos.t < k) {
					int[] posnew = pos.pos.clone();
					posnew[i]++;
					buy[q][i] = posmap.get(new Pos(pos.t + 1, posnew));
				} else
					buy[q][i] = -1;
				if (pos.pos[i] > 0) {
					int[] posnew = pos.pos.clone();
					posnew[i]--;
					sell[q][i] = posmap.get(new Pos(pos.t - 1, posnew));
				} else
					sell[q][i] = -1;
			}
		}

		// find the answer
		cc = new long[m + 1][poscnt];
		prev = new int[m + 1][poscnt];
		Arrays.fill(cc[0], -1);
		cc[0][0] = c0;

		for (int t = 0; t < m; t++) {
			Arrays.fill(cc[t + 1], -1);
			for (int q = 0; q < poscnt; q++) {
				long c = cc[t][q];
				if (c < 0)
					continue;
				update(t, q, q, c);
				for (int i = 0; i < n; i++) {
					if (buy[q][i] >= 0)
						update(t, q, buy[q][i], c - p[i][t] * si[i]);
					if (sell[q][i] >= 0)
						update(t, q, sell[q][i], c + p[i][t] * si[i]);
				}
			}
		}

		long c = cc[m][0];
		assert c <= 100000000000L;

		// construct the plan
		String[] op = new String[m];
		int qq = 0;
		for (int t = m; --t >= 0;) {
			int q = prev[t + 1][qq];
			if (q == qq) {
				op[t] = "HOLD";
				continue;
			}
			boolean found = false;
			for (int i = 0; i < n; i++) {
				if (buy[q][i] == qq) {
					op[t] = "BUY " + name[i];
					found = true;
					break;
				}
				if (sell[q][i] == qq) {
					op[t] = "SELL " + name[i];
					found = true;
					break;
				}
			}
			assert found;
			qq = q;
		}

		// write the answer
		PrintWriter out = new PrintWriter(System.out);
		out.printf(Locale.US, "%.2f%n", c / 100.0);
		for (int t = 0; t < m; t++)
			out.println(op[t]);
		out.close();
	}

	void update(int t, int q, int qq, long c) {
		if (c < 0)
			return; // cannot
		assert c <= 100000000000L + MAX_PORTFOLIO_COST; // max profit + max cost of all lots
		if (cc[t + 1][qq] < c) {
			cc[t + 1][qq] = c;
			prev[t + 1][qq] = q;
		}
	}

	void numPos(int i, int t, int[] pos) {
		if (i >= n) {
			Pos o = new Pos(t, pos);
			poslist.add(o);
			posmap.put(o, poscnt);
			poscnt++;
			return;
		}
		for (int j = 0; j <= Math.min(ki[i], k - t); j++) {
			pos[i] = j;
			numPos(i + 1, t + j, pos);
		}
	}

//----------------- just for validation ------------------

	/**
	 * Strict scanner to veryfy 100% correspondence between input files and input file format specification.
	 * It is a drop-in replacement for {@link java.util.Scanner} that could be added to a soulution source
	 * (cut-and-paste) without breaking its ability to work with {@link java.util.Scanner}.
	 */
	public class XScanner {
		private final BufferedReader in;
		private String line = "";
		private int pos;
		private int lineNo;
		private boolean localeset;

		public XScanner(Object source) throws FileNotFoundException {
			in = new BufferedReader(new InputStreamReader(System.in));
			nextLine();
		}

		public void close() {
			assert line == null : "Extra data at the end of file";
			try {
				in.close();
			} catch (IOException e) {
				throw new AssertionError("Failed to close with " + e);
			}
		}

		public void nextLine() {
			assert line != null : "EOF";
			assert pos == line.length() : "Extra characters on line " + lineNo;
			try {
				line = in.readLine();
			} catch (IOException e) {
				throw new AssertionError("Failed to read line with " + e);
			}
			pos = 0;
			lineNo++;
		}

		public String next() {
			assert line != null : "EOF";
			assert line.length() > 0 : "Empty line " + lineNo;
			if (pos == 0)
				assert line.charAt(0) > ' ' : "Line " + lineNo + " starts with whitespace";
			else {
				assert pos < line.length() : "Line " + lineNo + " is over";
				assert line.charAt(pos) == ' ' : "Wrong whitespace on line " + lineNo;
				pos++;
				assert pos < line.length() : "Line " + lineNo + " is over";
				assert line.charAt(0) > ' ' : "Line " + lineNo + " has double whitespace";
			}
			StringBuilder sb = new StringBuilder();
			while (pos < line.length() && line.charAt(pos) > ' ')
				sb.append(line.charAt(pos++));
			return sb.toString();
		}

		public int nextInt() {
			String s = next();
			assert s.length() == 1 || s.charAt(0) != '0' : "Extra leading zero in number " + s + " on line " + lineNo;
			assert s.charAt(0) != '+' : "Extra leading '+' in number " + s + " on line " + lineNo;
			try {
				return Integer.parseInt(s);
			} catch (NumberFormatException e) {
				throw new AssertionError("Malformed number " + s + " on line " + lineNo);
			}
		}

		public double nextDouble() {
			assert localeset : "Locale must be set with useLocale(Locale.US)";
			String s = next();
			assert s.length() == 1 || s.startsWith("0.") || s.charAt(0) != '0' : "Extra leading zero in number " + s + " on line " + lineNo;
			assert s.charAt(0) != '+' : "Extra leading '+' in number " + s + " on line " + lineNo;
			try {
				return Double.parseDouble(s);
			} catch (NumberFormatException e) {
				throw new AssertionError("Malformed number " + s + " on line " + lineNo);
			}
		}

		public void useLocale(Locale locale) {
			assert locale == Locale.US;
			localeset = true;
		}
	}
}
