#include <stdio.h>
#include <string.h>
int strGrade(char str[]) {
int length;
length = strlen(str);
if(str[length - 2] == ' ') {
return str[length - 1] - '0';
} else if(str[length -3] == ' ') {
return 10 * (str[length - 2] - '0') + (str[length - 1] - '0');
} else {
return 100;
}
}
void printStr(char str[]) {
int length;
length = strlen(str);
if(str[length - 2] == ' ') {
str[length - 2] = '\0';
} else if(str[length - 3] == ' '){
str[length - 3] = '\0';
} else {
str[length - 4] = '\0';
}
printf("%s\n", str);
}
int main() {
char str[30], maxStr[30], minStr[30];
int n, i, grade, maxGrade, minGrade;
scanf("%d", &n);
getchar();
for(i = 0; i < n; i ++) {
gets(str);
grade = strGrade(str);
if(i == 0) {
maxGrade = minGrade = grade;
strcpy(maxStr, str);
strcpy(minStr, str);
continue;
}
if(maxGrade < grade) {
maxGrade = grade;
strcpy(maxStr, str);
}
if(minGrade > grade) {
minGrade = grade;
strcpy(minStr, str);
}
}
printStr(maxStr);
printStr(minStr);
return 0;
}
#include <string.h>
int strGrade(char str[]) {
int length;
length = strlen(str);
if(str[length - 2] == ' ') {
return str[length - 1] - '0';
} else if(str[length -3] == ' ') {
return 10 * (str[length - 2] - '0') + (str[length - 1] - '0');
} else {
return 100;
}
}
void printStr(char str[]) {
int length;
length = strlen(str);
if(str[length - 2] == ' ') {
str[length - 2] = '\0';
} else if(str[length - 3] == ' '){
str[length - 3] = '\0';
} else {
str[length - 4] = '\0';
}
printf("%s\n", str);
}
int main() {
char str[30], maxStr[30], minStr[30];
int n, i, grade, maxGrade, minGrade;
scanf("%d", &n);
getchar();
for(i = 0; i < n; i ++) {
gets(str);
grade = strGrade(str);
if(i == 0) {
maxGrade = minGrade = grade;
strcpy(maxStr, str);
strcpy(minStr, str);
continue;
}
if(maxGrade < grade) {
maxGrade = grade;
strcpy(maxStr, str);
}
if(minGrade > grade) {
minGrade = grade;
strcpy(minStr, str);
}
}
printStr(maxStr);
printStr(minStr);
return 0;
}