#include<stdio.h>
struct student{
    int age;
    char name[4];
};
int main(void)
{
    int i,index,j;
    struct student students[4],temp;

    for(i=0;i<4;i++)
    {
        scanf("%d",&students[i].age);
        scanf("%s",students[i].name);
}
for(i=0;i<4-1;i++) { index=i; for(j=i+1;j<4;j++) if(students[j].age<students[index].age) index=j; temp=students[index]; students[index]=students[i]; students[i]=temp; } for(i=0;i<4;i++) printf("%d %s\n",students[i].age,students[i].name); return 0; }