#include <stdio.h>

#define MAXN    100
#define MAXK    300
#define INF     1000000000;

int maskLength[] = { 0, 1, 1, 2, 1, 2, 2, 3 };
int us[MAXN];
int uh[MAXN];
int uw[MAXN];
int ts[MAXN];
int th[MAXN];
int tw[MAXN];
int soldCost[MAXN][8];

int ansPeople[MAXN];
int testNum;
int curPeople;
int testWho[MAXK];
int testType[MAXK];
int ans[MAXN + 1][MAXN + 1][MAXK + 1];

int max(int a, int b) {
    return (a > b) ? a : b;
}

int getCost(int u, int mask) {
    int result = 0;
    if ((mask & 1) != 0) {
        result += ts[u];  
    } else {
        result += us[u];
    }
    if ((mask & 2) != 0) {
        result += th[u];  
    } else {
        result += uh[u];
    }
    if ((mask & 4) != 0) {
        result += tw[u];  
    } else {
        result += uw[u];
    }
    return result;
}

void printAnswer(int n, int m, int k) {
    if (n == 0) {
        return;
    }
    
    if (ans[n][m][k] == ans[n - 1][m][k]) {
        printAnswer(n - 1, m, k);
        return;
    }
    
    ansPeople[curPeople++] = n;
    for (int mask = 0; mask < 8; mask++) {
        if (k >= maskLength[mask]) {
            int cur = soldCost[n - 1][mask] + ans[n - 1][m - 1][k - maskLength[mask]];
            if (cur == ans[n][m][k]) {
                if ((mask & 1) != 0) {
                    testWho[testNum] = n;
                    testType[testNum] = 1;
                    testNum++;
                }
                    
                if ((mask & 2) != 0) {
                    testWho[testNum] = n;
                    testType[testNum] = 2;
                    testNum++;
                }
                
                if ((mask & 4) != 0) {
                    testWho[testNum] = n;
                    testType[testNum] = 3;
                    testNum++;
                }
                
                printAnswer(n - 1, m - 1, k - maskLength[mask]);
                return;
            }
        }
    }
}

int main() {
    int n, m, k;

    freopen("soldiery.in", "r", stdin);
    freopen("soldiery.out", "w", stdout);

    scanf("%d %d %d", &n, &m, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d %d %d %d", &us[i], &uh[i], &uw[i], &ts[i], &th[i], &tw[i]);
    }

    for (int i = 0; i < n; i++) {
        for (int mask = 0; mask < 8; mask++) {
            soldCost[i][mask] = getCost(i, mask);
        }
    }

    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= k; j++) {
            ans[0][i][j] = -INF;
        }
    }
    ans[0][0][0] = 0;
    
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            for (int t = 0; t <= k; t++) {
                ans[i][j][t] = ans[i - 1][j][t];
                if (j == 0) {
                    continue;
                }
                for (int mask = 0; mask < 8; mask++) {
                    if (t >= maskLength[mask]) {
                        int cur = soldCost[i - 1][mask] + ans[i - 1][j - 1][t - maskLength[mask]];
                        ans[i][j][t] = max(ans[i][j][t], cur);
                    }
                }
            }
        }
    }

    int answer = 0;
    int ansi = 0;
    for (int i = 0; i <= k; i++) {
        if (ans[n][m][i] > answer) {
            answer = ans[n][m][i];
            ansi = i;
        }
    }
    
    curPeople = 0;
    testNum = 0;
    printAnswer(n, m, ansi);
    
    printf("%d %d\n", answer, testNum);
    for (int i = 0; i < testNum; i++) {
        printf("%d ", testWho[i]);
        if (testType[i] == 1) {
            printf("STRENGTH\n");
        } else if (testType[i] == 2) {
            printf("HEIGHT\n");
        } else if (testType[i] == 3) {
            printf("WEIGHT\n");
        }
    }

    for (int i = m - 1; i >= 0; i--) {
        printf("%d ", ansPeople[i]);
    }
    printf("\n");
}
