/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: hdblo
 *
 * Created on 28 de Maio de 2019, 22:07
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int strpos(char s[], char p[]);

int main(int argc, char** argv) {
    int a = 0;
    char linha[10];
    char csplit[2] = " ";
    char ing[9][17] = {"Milho verde", "Oleo vegetal", "Acucar", "Fuba", "Ovos", "Farinha de trigo", "Coco ralado", "Fermento em po", "Leite de coco"};
    int qr[9][3] = {
        {200, 0, 0},
        {200, 120, 0},
        {250, 360, 0},
        {200, 0, 0},
        {4, 4, 0},
        {15, 240, 0},
        {15, 100, 0},
        {5, 10, 0},
        {0, 200, 0}
    };
    char med[9][3] = {"Kg", "L", "Kg", "Kg", "", "Kg", "Kg", "Kg", "L"};

    while (a == 0) {

        gets(linha);

        if (linha[0] == '0') {
            a = 1;
            break;
        }

        int q = atoi(linha);

        for (int x = 0; x < q; x++) {
            gets(linha);
            int t = strlen(linha);
            char valores[11];
            int p = strpos(linha, csplit);
            char milho[5] = "";
            char coco[5] = "";
            strncpy(milho, linha, p);
            milho[p + 1] = '\0';
            for (int n = p; n < strlen(linha) - 1; n++) {
                coco[n - p] = linha[n + 1];
            }
            coco[strlen(linha) - p] = '\0';
            int m = atoi(milho);
            int c = atoi(coco);
            for (int i = 0; i<9; i++) {
                qr[i][2] = qr[i][2] + qr[i][0] * m;
                qr[i][2] = qr[i][2] + qr[i][1] * c;
            }
        }

        for (int x = 0; x < 9; x++) {
            if(!strcmp(med[x],"")){
                printf("%s %i%s\n", ing[x], qr[x][2], med[x]);
            }else{
                printf("%s %i%s\n", ing[x], ((int)qr[x][2])/1000, med[x]);
            }
        }

    }

    return (EXIT_SUCCESS);
}

int strpos(char s[], char p[]) {
    for (int x = 0; x <= strlen(s); x++) {
        if (s[x] == p[0]) {
            return x;
        }
    }
    return -1;
}