#include <stdio.h>#include <string.h>#include <stdlib.h>typedef struct { char name[24]; int w;}PERSON;int cmp(const void* x, const void* y){ return ((PERSON*)y)->w - ((PERSON*)x)->w;}int main(void){ char s[8], first = 1; PERSON person[12]; int a, b; while(scanf("%s", s) != EOF) { int cnt = 0; while(1) { scanf("%s", person[cnt].name); if(strcmp(person[cnt].name, "END") == 0) break; scanf("%d%d", &a, &b); person[cnt].w = b - a; ++ cnt; } qsort(person, cnt, sizeof(PERSON), cmp); if(first) first = 0; else putchar('n'); for(a = 0; a < cnt; ++a) puts(person[a].name); } return 0;}