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

public class soldiery_ia implements Runnable {

	private BufferedReader in;
	private PrintWriter out;
	final String defaultMessage = "wrong input format.";
	private int lineNumber;
	private int n, m, k;
	private int[][] a, b;

	public void run() {
		try {
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	private void solve() throws IOException {
		in = new BufferedReader(new FileReader("soldiery.in"));
		out = new PrintWriter("soldiery.out");
		lineNumber = 0;
		String str = in.readLine();
		lineNumber++;
		StringTokenizer st = new StringTokenizer(str);
		n = Integer.parseInt(st.nextToken());
		m = Integer.parseInt(st.nextToken());
		k = Integer.parseInt(st.nextToken());
		assertEquality(n + " " + m + " " + k, str, null);
		final int MAXN = 100;
		final int MAXK = 300;
		final int MAXPARAM = 100000;
		assertBounds(n, 1, MAXN, "N");
		assertBounds(m, 1, n, "M");
		assertBounds(k, 0, MAXK, "K");
		
		a = new int[3][n];
		b = new int[3][n];
		for (int i = 0; i < n; i++) {
			str = in.readLine();
			lineNumber++;
			st = new StringTokenizer(str);
			for (int z = 0; z < 3; z++) {
				a[z][i] = Integer.parseInt(st.nextToken());
			}
			for (int z = 0; z < 3; z++) {
				b[z][i] = Integer.parseInt(st.nextToken());
			}
			assertEquality(a[0][i] + " " + a[1][i] + " " + a[2][i] + " " + b[0][i] + " " + b[1][i] + " " + b[2][i], str, null);
			for (int z = 0; z < 3; z++) {
				assertBounds(a[z][i], 0, MAXPARAM, "one of parametrs");
				assertBounds(b[z][i], 0, MAXPARAM, "one of parametrs");
			}
		}
		str = in.readLine();
		lineNumber++;
		assertStatement(str == null, null);
		in.close();
		lineNumber = -1;
		
		int[][][] x = new int[n + 1][m + 1][k + 1];
		int[][][] from = new int[n + 1][m + 1][k + 1];
		boolean[] r = new boolean[3];
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= m; j++) {
				for (int p = 0; p <= k; p++) {
					x[i][j][p] = -1000000000;
				}
			}
		}
		x[0][0][0] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= m; j++) {
				for (int p = 0; p <= k; p++) {
					if (x[i + 1][j][p] < x[i][j][p]) {
						x[i + 1][j][p] = x[i][j][p];
						from[i + 1][j][p] = -1;
					}
					if (j == m) {
						continue;
					}
					for (int z = 0; z < 8; z++) {
						int pp = p;
						int s = 0;
						for (int t = 0; t < 3; t++) {
							r[t] = (z & (1 << t)) != 0;
							if (r[t]) {
								pp++;
								s += b[t][i];
							} else {
								s += a[t][i];
							}
						}
						if (pp > k) {
							continue;
						}
						int xx = x[i][j][p] + s;
						if (x[i + 1][j + 1][pp] < xx) {
							x[i + 1][j + 1][pp] = xx;
							from[i + 1][j + 1][pp] = z;
						}
					}
				}
			}
		}
		
		int bestp = 0;
		for (int p = 0; p <= k; p++) {
			if (x[n][m][p] > x[n][m][bestp]) {
				bestp = p;
			}
		}
		
		k = bestp;
		
		out.println(x[n][m][bestp] + " " + bestp);
		int[] soldiers = new int[m];
		int[] et = new int[k];
		int[] es = new int[k];
		
		while (n > 0) {
			int z = from[n][m][k];
			n--;
			if (z >= 0) {
				m--;
				soldiers[m] = n + 1;
				for (int t = 0; t < 3; t++) {
					r[t] = (z & (1 << t)) != 0;
					if (r[t]) {
						k--;
						et[k] = t;
						es[k] = n + 1;
					}
				}
			}
		}
		assertStatement((k | m) == 0, "internal error.");
		
		k = bestp;
		for (int i = 0; i < k; i++) {
			String examName = null;
			switch (et[i]) {
			case 0:
				examName = "STRENGTH";
				break;
			case 1:
				examName = "HEIGHT";
				break;
			case 2:
				examName = "WEIGHT";
				break;
			default:
				assertStatement(false, "internal error.");
				break;
			}
			out.println(es[i] + " " + examName);
		}
		
		Arrays.sort(soldiers);
		out.print(soldiers[0]);
		for (int i = 1; i < soldiers.length; i++) {
			out.print(" " + soldiers[i]);
		}
		out.close();
	}

	private void assertBounds(int n, int lo, int hi, String varName) {
		assertStatement(n >= lo && n <= hi, varName + " is out of bounds.");
	}

	private void assertEquality(String s1, String s2, String msg) {
		assertStatement(s1.equals(s2), msg);
	}

	private void assertStatement(boolean st, String msg) {
		if (msg == null) {
			msg = defaultMessage;
		}
		if (lineNumber != -1) {
			msg = "Line " + lineNumber + ": " + msg;
		}
		if (!st) {
			System.out.println(msg);
			out.println(msg);
			out.close();
			throw new Error(msg);
		}
	}

	public static void main(String[] args) {
		new Thread(new soldiery_ia()).start();
	}

}
