import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;


public class soldiery_dp implements Runnable {

	private static final int INF = 1000000000;
	private static final String[] NAME = new String[] {
		"STRENGTH",
		"HEIGHT",
		"WEIGHT"
	};
	
	private Scanner in;
	private PrintWriter out;
	private int[][] info;
	private int[] answer;
	private byte[] type;
	private int nn;
	private int mm;
	private int kk;

	public void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		int k = in.nextInt();
		info = new int[n][6];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 6; j++) {
				info[i][j] = in.nextInt();
			}
		}
		nn = n + 1;
		mm = m + 1;
		kk = k + 1;
		answer = new int[nn * mm * kk];
		type = new byte[nn * mm * kk];
		Arrays.fill(answer, -1);
		int currN = n;
		int currM = m;
		int currK = k;
		int currAns = 0;
		for (int i = 0; i <= k; i++) {
			int tmp = solve(currN, currM, i);
			if (currAns < tmp) {
				currAns = tmp;
				currK = i;
			}
		}
		Stack<Integer> answer = new Stack<Integer>();
		out.println(currAns + " " + currK);
		for (; currN > 0; currN--) {
			int t = type[(currN * mm + currM) * kk + currK];
			if (t == 8) {
				continue;
			}
			answer.push(currN);
			currM--;
			for (int i = 0; i < 3; i++) {
				if ((t >> i) % 2 == 1) {
					out.println(currN + " " + NAME[i]);
					currK--;
				}
			}
		}
		while (answer.size() > 0) {
			out.print(answer.pop() + " ");
		}
	}
	
	private int solve(int n, int m, int k) {
		if (n == 0 && m == 0 && k == 0) {
			return 0;
		}
		if (n <= 0 || m < 0 || k < 0) {
			return -INF;
		}
		int previousAnswer = answer[(n * mm + m) * kk + k];
		if (previousAnswer >= 0) {
			return previousAnswer;
		}
		int ans = solve(n - 1, m, k);
		int typ = 8;
		int[] inf = info[n - 1];
		for (int mask = 0; mask < 8; mask++) {
			int cnt = 0;
			int sum = 0;
			for (int i = 0; i < 3; i++) {
				if ((mask >> i) % 2 == 1) {
					cnt++;
					sum += inf[3 + i];
				} else {
					sum += inf[i];
				}
				int tmp = sum + solve(n - 1, m - 1, k - cnt);
				if (ans < tmp) {
					ans = tmp;
					typ = mask;
				}
			}
		}
		type[(n * mm + m) * kk + k] = (byte) typ;
		return answer[(n * mm + m) * kk + k] = Math.max(0, ans);
	}

	public void run() {
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public soldiery_dp(String file) {
		try {
			in = new Scanner(new File(file + ".in"));
			out = new PrintWriter(new File(file + ".out"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			System.exit(239);
		}
	}

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