/*
#include <stdio.h>
int main()
{
int a,b,c,i,max=0;
scanf("%d %d %d",&a,&b,&c);
for(i=a; i>=1; i--)
{
if(a%i==0&&b%i==0&&c%i==0)
{
printf("%d",i);
return 0;
}
}
}
*/
/*
#include <stdio.h>
int a[10001];
int n, i, j, temp;
int main() {
scanf("%d", &n);
for (i=1; i<=n; i++)
scanf("%d", &a[i]);
for(i=1; i<n; i++)
{
for(j=1;j<=n-i;j++)
{
if (a[j] < a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
for (i = 1; i <= n; i++)
printf("%d ", a[i]);
return 0;
버블정렬
}
*/
/*
#include <stdio.h>
int a[10001];
int n, i, j, temp, min;
int main()
{
scanf("%d", &n);
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (i=1; i<n; i++)
{
min=i; //min : 최솟값의 위치
for (j=i+1; j<=n; j++)
{
if(a[min]<a[j])
{
min=j;
}
}
temp = a[i];
a[i] = a[min];
a[min] = temp;
}
for (i=1; i<=n; i++)
printf("%d\n", a[i]);
return 0;
}
*/
/*
#include <stdio.h>
typedef struct
{
int age;
float score;
char grade;
}student;
int main()
{
student arr[101];
//scanf("%d",&a.age);
//arr[0] ~ arr[100]
arr[1].age=10;
arr[2].age=20;
for(int i=1;i<=10;i++)
{
scanf("%d",&arr[i].age);
}
}
구조체 + 버블정렬
*/
#include <stdio.h>
typedef struct
{
char name[11];
int score;
} student;
int main()
{
int i,n,m,j;
student a[101],temp;
scanf("%d %d ",&n,&m);
for(i=1;i<=n;i++)
{
scanf("%s %d",a[i].name,&a[i].score);
}
for(i=1;i<n;i++)
{
for(j=1;j<=n-i;j++)
{
if(a[j].score<a[j+1].score)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(i=1;i<=m;i++)
printf("%s\n",a[i].name);
return 0;
}
/*
#include <stdio.h>
int a[10001];
int n, i, j, temp;
int main()
{
scanf("%d", &n);
for (i=1; i<=n; i++)
scanf("%d", &a[i]);
for(i=1; i<n; i++)
{
for(j=1; j<=n-i; j++)
{
if (a[j] < a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
for (i = 1; i <= n; i++)
printf("%d ", a[i]);
return 0;
}
*/