#include<stdio.h>
#include<string.h>
#define N 40
#define M 5
int main()
{
struct book
{
char name[N] ;
float value ;
};
struct book books[M];
int n ,i ;
float max ,min;
char max_name[N] , min_name[N];
scanf("%d",&n);
//读走缓存区中的回车
getchar();
for(i = 0 ;i < n; i++)
{
gets(books[i].name);
scanf("%f",&books[i].value);
//读走缓存区中的回车
getchar();
}
max = books[0].value ;
min = books[0].value;
for(i = 0 ;i < n; i++)
{
if(books[i].value > max)
{
max = books[i].value ;
strcpy(max_name, books[i].name);
}
}
for(i = 0 ; i<n;i++)
{
if(books[i].value < min)
{
min = books[i].value;
strcpy(min_name, books[i].name);
}
}
printf("%.2f , %s\n",max,max_name);
printf("%.2f , %s\n",min,min_name);
return 0 ;
}