#include using namespace std; using i64 = int64_t; struct Book{ string s, id; bool operator<(const Book &obj)const{ if(s == obj.s)return id < obj.id; return s < obj.s; } }; int main(){ int n; cin >> n; vector v; for(int i=0;i> s >> id; v.push_back((Book){s, id}); } sort(v.begin(), v.end()); for(auto e:v){ cout << e.s << " " << e.id << endl; } return 0; }