#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<string, int> population;
    int n, i, x;
    string country;

    cin>>n;
    for(i=0; i<n; i++){
        cin>> country >> x;
        population[country]=x;
    }
    map<string, int>::iterator it;
    for(it=population.begin(); it!=population.end(); it++){
        cout<< it->first << " " << it->second <<endl;
    }


    return 0;
}
