#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
using namespace std;
typedef tuple<int, int, char, long long, string> item;
int main()
{
    int n;
    cin >> n;
    vector<item> A;
    A.reserve(n); //要素数を予約
    for (int i = 0; i < n; i++)
    {
        int v, w;
        long long d;
        char t;
        string s;
        cin >> v >> w >> t >> d >> s;
        A.push_back(make_tuple(v, w, t, d, s));
    }
    sort(A.begin(), A.end());

    for (auto it = A.begin(); it != A.end(); it++)
    {
        item T = *it;
        const int &v = get<0>(T);
        const int &w = get<1>(T);
        const char &t = get<2>(T);
        const long long &d = get<3>(T);
        const string &s = get<4>(T);
        cout << v << ' ' << w << ' ' << t << ' ' << d << ' ' << s << endl;
    }
}
