#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
struct q {
int a;
char b[200];
q()
{
a = 0;
}
bool operator < (const q &A)const
{
return a < A.a;
}
} Q[51];
int n;
int main()
{
freopen("nba.in", "r", stdin);
freopen("nba.out", "w", stdout);
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%[^0-9]%d", &Q[i].b, &Q[i].a);
Q[i].b[0] = ' ';
}
sort(Q + 1, Q + n + 1);
for (int i = 1; i <= n; i++)if (Q[i].a != Q[i + 1].a) {
cout << Q[i].a << ' ' << Q[i].b << endl;
}
return 0;
}
//这道题用结构体就行
//第一步:定义结构体
//第二步:输入加排序(详细的见程序)
//第三步:输出