/*
 * 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, 20:55
 */

#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[23];
    char csplit[2] = " ";

    while (a == 0) {

        gets(linha);

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

        int q = atoi(linha);

//        printf("%i",q);
        
        char carro[q][8];
        float consumo[q];
        int c = 0;
        float cgeral = 0.0;

        for (int x = 0; x < q; x++) {
            gets(linha);
            int t = strlen(linha);
            char valores[15];
            strncpy(carro[c], linha, 7);
            carro[c][8]='\0';
            for (int n = 8; n < strlen(linha) - 1; n++) {
                valores[n - 8] = linha[n];
            }
            int i = strpos(valores, csplit);
            char kmc[8];
            strncpy(kmc, valores, 8);
            float km = atof(kmc);
            char ltc[7];
            for (int n = i; n < strlen(valores) - 1; n++) {
                ltc[n - i] = valores[n];
            }
            float lt = atof(ltc);
            consumo[c] = km / lt;
            cgeral += consumo[c];
//            printf("%s %f %f %f\n", carro[c], km, lt, consumo[c]);
            c++;
        }
        
        cgeral /= q;
        
        for(int x=0;x<q;x++){
            if(consumo[x]<cgeral){
                printf("%s\n",carro[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;
}