#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using P = pair; //const ll mod = 1000000007; const ll mod = 998244353; const ld pi = 3.14159265358979; int main() { //ios::sync_with_stdio(false); //cin.tie(0); //cout << fixed << setprecision(15); int n; cin >> n; vector> S(n); for(int i = 0; i < n; i++){ string a , b; cin >> a >> b; S[i] = make_pair(a , b); } sort(S.begin() , S.end()); for(int i = 0; i < n; i++){ cout << S[i].first << " " << S[i].second << endl; } return 0; }