#include<stdio.h>
struct student{
int num;
char name[4];
};
int main(void)
{
int i,x,j;
struct student students[50],y;
for(i=0;i<4;i++){
scanf("%d%s",&students[i].num,&students[i].name);
}
for(i=0;i<3;i++){
x=i;
for(j=i+1;j<4;j++)
if(students[j].num<students[x].num)
x=j;
y=students[x];
students[x]=students[i];
students[i]=y;
}
for(i=0;i<4;i++)
printf("%d %s
",students[i].num,students[i].name);
return 0;
}