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

public class fund_rs implements Runnable {
	private BufferedReader in;
	private PrintWriter out;
	
	private class Stock {
		public String name;
		public int k;
		public long[] costs;

		public Stock(BufferedReader in) throws IOException {
			StringTokenizer st = new StringTokenizer(in.readLine());
			name = st.nextToken();
			long s = Integer.parseInt(st.nextToken());
			k = Integer.parseInt(st.nextToken());
			st = new StringTokenizer(in.readLine());
			costs = new long[days];
			for (int i = 0; i < days; i++) {
				costs[i] = s * Math.round(100 * Double.parseDouble(st.nextToken()));
			}
		}
	}
	
	private Stock[] stocks;
	private int[][] decode;
	private int[] p;
	private int days;
	private int maxLots;
	private int currentStateNumber;
	private long[][] ans;
	private int[][] action;
	private int[][] go;
	private int[] goNumber;
	private int bsize;
	
	private int encode(int[] z) {
		int curPos = 0;
		for (int i = 0; i < z.length; i++) {
			curPos = go[curPos][z[i]];
		}
		return goNumber[curPos];
	}
	
	private void generateStates(int u, int leftLimit) {
		if (u == stocks.length) {
			int curPos = 0;
			for (int i = 0; i < stocks.length; i++) {
				decode[currentStateNumber][i] = p[i];
				if (go[curPos][p[i]] == -1) {
					go[curPos][p[i]] = bsize;
					Arrays.fill(go[bsize], -1);
					bsize++;
				}
				curPos = go[curPos][p[i]];
			}
			goNumber[curPos] = currentStateNumber; 
			currentStateNumber++;
			return;
		}
		
		for (int i = 0; (i <= stocks[u].k) && (i <= leftLimit); i++) {
			p[u] = i;
			generateStates(u + 1, leftLimit - i);
		}
	}

	private void printActions(int currentDay, int currentState) {
		if (currentDay == 0) {
			return;
		}
		if (action[currentDay][currentState] == 0) {
			printActions(currentDay - 1, currentState);
			out.println("HOLD");
			return;
		}
		int stock = Math.abs(action[currentDay][currentState]) - 1; 
		for (int j = 0; j < stocks.length; j++) {
			p[j] = decode[currentState][j];
		}
		if (action[currentDay][currentState] > 0) {
			p[stock]++;
			int prevState = encode(p);
			p[stock]--;
			printActions(currentDay - 1, prevState);
			out.println("SELL " + stocks[stock].name);
		} else {
			p[stock]--;
			int prevState = encode(p);
			p[stock]++;
			printActions(currentDay - 1, prevState);
			out.println("BUY " + stocks[stock].name);
		}
	}

	private void solve() throws IOException {
		Locale.setDefault(Locale.US);
		StringTokenizer st = new StringTokenizer(in.readLine());
		long c = Math.round(100 * Double.parseDouble(st.nextToken()));
		days = Integer.parseInt(st.nextToken());
		int n = Integer.parseInt(st.nextToken());
		maxLots = Integer.parseInt(st.nextToken());
		
		stocks = new Stock[n];
		for (int i = 0; i < n; i++) {
			stocks[i] = new Stock(in);
		}
		
		p = new int[n];
		currentStateNumber = 0;
		decode = new int[13000][n];
		go = new int[25000][9];
		goNumber = new int[25000];
		bsize = 1;
		Arrays.fill(go[0], -1);
		generateStates(0, maxLots);
		
		ans = new long[days + 1][currentStateNumber];
		action = new int[days + 1][currentStateNumber];
		for (int i = 0; i <= days ; i++) {
			Arrays.fill(ans[i], -1);
		}
		ans[0][0] = c;
		for (int i = 0; i < days; i++) {
			for (int state = 0; state < currentStateNumber; state++) {
				long currentMoney = ans[i][state];
				if (currentMoney < 0) {
					continue;
				}
				for (int j = 0; j < n; j++) {
					p[j] = decode[state][j];
				}
				
				// SELL
				int currentLots = 0;
				for (int j = 0; j < n; j++) {
					currentLots += p[j];
					if (p[j] > 0) {
						p[j]--;
						int newState = encode(p);
						p[j]++;
						
						// update
						long addon = stocks[j].costs[i];
						if (currentMoney + addon > ans[i + 1][newState]) {
							ans[i + 1][newState] = currentMoney + addon;
							action[i + 1][newState] = j + 1;
						}
					}
				}
				
				// HOLD
				if (ans[i][state] > ans[i + 1][state]) {
					ans[i + 1][state] = ans[i][state];
					action[i + 1][state] = 0;
				}
				
				// BUY
				if (currentLots < maxLots) {
					for (int j = 0; j < n; j++) {
						if (p[j] < stocks[j].k) {
							p[j]++;
							int newState = encode(p);
							p[j]--;
							
							// update
							long addon = -stocks[j].costs[i];
							if (currentMoney + addon > ans[i + 1][newState]) {
								ans[i + 1][newState] = currentMoney + addon;
								action[i + 1][newState] = -(j + 1);
							}
						}
					}
				}
			}
		}
		out.println(ans[days][0] / 100 + "." + (ans[days][0] % 100) / 10 + "" + ans[days][0] % 10);
		printActions(days, 0);
	}
	
	public static void main(String[] args) {
		new Thread(new fund_rs()).start();
	}

	public void run() {
		String problem = getClass().getName().split("_")[0];
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}
