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

public class soldiery_is implements Runnable {
	String className = soldiery_is.class.getName();
	{
		className = className.substring(0, className.indexOf('_'));
	}
	BufferedReader in;
	private StringTokenizer st;
	PrintWriter out;
	
	soldiery_is() {
		try {
			in = new BufferedReader(new FileReader(className + ".in"));
			st = new StringTokenizer("");
			out = new PrintWriter(className + ".out");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
	}
	
	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}
	
	int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(next());
	}
	
	class A {
		int[] a = new int[3];
		int[] b = new int[3];
		int[] r = new int[8];
		
		void get() throws NumberFormatException, IOException {
			for (int i = 0; i < 3; i++) {
				a[i] = nextInt();
			}
			for (int i = 0; i < 3; i++) {
				b[i] = nextInt();
			}
			for (int i = 0; i < 8; i++) {
				r[i] = 0;
				for (int j = 0; j < 3; j++) {
					if ((i & (1 << j)) == 0) {
						r[i] += a[j];
					} else {
						r[i] += b[j];
					}
				}
			}
		}				
	}

	public void run() {
		try {
			final int n = nextInt();
			final int m = nextInt();
			final int k = nextInt();			
			A[] s = new A[n];
			for (int i = 0; i < n; i++) {
				s[i] = new A();
				s[i].get();
			}
			int[] rv = new int[]{0,1,1,2,1,2,2,3};
			int[][][] a = new int[n + 1][m + 1][k + 1];
			for (int[] aij : a[0]) {
				Arrays.fill(aij, Integer.MIN_VALUE);
			}
			a[0][0][0] = 0;
			int[][][] p = new int[n + 1][m + 1][k + 1];								
			for (int sin = 0; sin < n; sin++) {
				int[] sir = s[sin].r;
				int[][] ap = a[sin];				
				int[][] an = a[sin + 1];
				int[][] pn = p[sin + 1];
				for (int mi = 0; mi <= m; mi++) {
					for (int ki = 0; ki <= k; ki++) {
						an[mi][ki] = ap[mi][ki];
						pn[mi][ki] = -1;						
					}				
				}
				for (int mi = 0; mi < m; mi++) {
					for (int ki = 0; ki <= k; ki++) {
						for (int ri = 0; ri < 8; ri++) {							
							int mn = mi + 1;
							int kn = ki + rv[ri];
							if (kn > k) {
								continue;
							}
							int anmk = ap[mi][ki] + sir[ri];
							if (an[mn][kn] < anmk) {
								an[mn][kn] = anmk;
								pn[mn][kn] = ri;
							}
						}
					}
				}
			}
			int ans = -1;
			int ki = k;
			for (int kii = 0; kii <= k; kii++) {
				if (ans < a[n][m][kii]) {
					ans = a[n][m][kii];
					ki = kii;
				}
			}
			int ni = n;
			int mi = m;
			out.println(ans + " " + ki);
			TreeSet<Integer> take = new TreeSet<Integer>();
			String[] param = new String[]{"STRENGTH", "HEIGHT", "WEIGHT"}; 
			while (ni > 0) {
				int pi = p[ni][mi][ki];
				if (pi >= 0) {
					mi--;
					take.add(ni);
					for (int i = 0; i < 3; i++) {
						if ((pi & (1 << i)) != 0) {						
							out.println(ni + " " + param[i]);
							ki--;
						}
					}
				}
				ni--;
			}
			for (Integer ti : take) {
				out.print(ti + " ");
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			out.close();
		}
		
	}
	
	public static void main(String[] args) {
		new Thread(new soldiery_is()).run();
	}
	
}
