#include<bits/stdc++.h>
using namespace std;
const int N = 110;
int n;

string buf[N];

int main()
{
	while(cin >> n)
	{
		for(int i = 0; i < n; i ++) 
		{
			int x; 
			string color; 
			cin >> x >> color;
			buf[x] = color;
		}
		
		for(int i = N - 1; i >= 0; i--)
		{
			if(buf[i].size() != 0) cout << buf[i] << endl;
		}
	}
	return 0;
}