using namespace std;
#include <bits/stdc++.h>

int numRealChar(string& s);

int main() {

    string line;
    getline(cin, line);
    int n = stoi(line);
    map<string,string> mymap;

    // Process cases.
    for (int i=0; i<n; i++) {

        getline(cin, line);

        int idx = 0;
        while (line[idx] < 'A' || line[idx] > 'Z' ) idx++;

        // Last name.
        string key = line.substr(idx, line.size()-idx);

        // Add to map.
        mymap[key] = line;
    }

    for (auto x=mymap.begin(); x != mymap.end(); x++)
        cout << (*x).second << endl;

    return 0;
}

int numRealChar(string& s) {
    int res =0;
    for (int i=0; i<s.size(); i++)
        if (s[i] != ' ')
            res++;
    return res;
}
