#include #include #include #include #include #include #include #define REP(i,a) for(int i = 0; i < (a); i++) using namespace std; int main(){ int n; cin >> n; string s[n],id[n]; vector > pairs(n); REP(i, n){ cin >> s[i] >> id[i]; pairs[i] = make_pair(s[i], id[i]); } sort(pairs.begin(), pairs.end()); REP(i, n){ cout << pairs[i].first << " " << pairs[i].second << endl; } }