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

public class soldiery_ft_greedy2 implements Runnable {

	private Scanner in;
	private PrintWriter out;

	private void myAssert(boolean e, String mes) {
		if (!e) {
			throw new Error("Assertion failure!!! " + mes);
		}
	}

	class Offer implements Comparable<Offer>  {
		int num;
		String type;

		int val;
		int index;
		int delta;
		Solder s;

		public Offer(int num, String type, int val, int index, Solder s, int delta) {
			this.num = num;
			this.type = type;
			this.val = val;
			this.index = index;
			this.s = s;
			this.delta = delta;
		}

		public String toString() {
			return num + " " + type;
		}


		public int compareTo(Offer that) {
			return -(delta - that.delta);
		}

		public void apply() {
			s.fake[index] = val;
		}

	}

	class Solder implements Comparable<Solder> {
		int[] real;
		int[] fake;
		int id;
		public Solder(int a1, int b1, int c1, int a2, int b2, int c2, int id) {
			real = new int[3];
			fake = new int[3];			
			real[0] = a2;
			real[1] = b2;
			real[2] = c2;
			fake[0] = a1;
			fake[1] = b1;
			fake[2] = c1;
			this.id = id;
		}

		public int compareTo(Solder that) {
			return -(fake[0] + fake[1] + fake[2] - that.fake[0] - that.fake[1] - that.fake[2]);
		}

	}

	private void solve() throws IOException {
		int n = in.nextInt();
		int m = in.nextInt();
		int k = in.nextInt();
		Solder[] s = new Solder[n];
		for (int i = 0; i < n; i++) {
			s[i] = new Solder(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), i + 1);
		}
		
		ArrayList<Offer> list = new ArrayList<Offer>();
        
		for (int i = 0; i < n; i++) {
			if (s[i].fake[0] < s[i].real[0]) {
				list.add(new Offer(i + 1, "STRENGTH", s[i].real[0], 0, s[i], s[i].fake[0] - s[i].real[0]));
			}
			if (s[i].fake[1] < s[i].real[1]) {
				list.add(new Offer(i + 1, "HEIGHT", s[i].real[1], 1, s[i], s[i].fake[1] - s[i].real[1]));
			}
			if (s[i].fake[2] < s[i].real[2]) {
				list.add(new Offer(i + 1, "WEIGHT", s[i].real[2], 2, s[i], s[i].fake[2] - s[i].real[2]));
			}
		}

		Collections.sort(list);

		ArrayList<String> ans = new ArrayList<String>();

		for (int i = 0; i < Math.min(k, list.size()); i++) {
			ans.add(list.get(i).toString());
			list.get(i).apply();
		}

		Arrays.sort(s);
		
		ArrayList<Integer> take = new ArrayList<Integer>();

		int sum = 0;
		for (int i = 0; i < m; i++) {
			sum += s[i].fake[0] + s[i].fake[1] + s[i].fake[2];
			take.add(s[i].id);
		}

		out.println(sum + " " + Math.min(k, list.size()));
		for (String ss : ans) {
			out.println(ss);
		}
		Collections.sort(take);
		for (Integer i : take) {
			out.print(i + " ");
		}		
		out.println();
		

	}

	public void run() {
		try {
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}
	
	private soldiery_ft_greedy2(String name) {
		try {
			in = new Scanner(new File(name + ".in"));
			out = new PrintWriter(new FileWriter(name + ".out"));	
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(239);
		}
	}

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