#include<iostream>
#include<string>
using namespace std;

class tuples
{
    private:
        int value;
        int weight;
        char type;
        unsigned long long date;
        string name;
    public:
        void input( int v, int w, char t, unsigned long long d, string s );
        void output();
        int rv(){ return value; }
        int rw(){ return weight; }
        char rt(){ return type; }
        unsigned long long rd(){ return date; }
        string rn(){ return name; }
};

void merge( tuples* x, int left, int mid, int right );
void mergeSort( tuples* x, int left, int right );

int main()
{
    int n;
    int v, w;
    char t;
    unsigned long long d;
    string s;

    cin >> n;

    tuples T[n];

    for( int i = 0; i < n; i++ )
    {
        cin >> v >> w >> t >> d >> s;
        T[i].input( v, w, t, d , s );
    }

    mergeSort( T, 0, n );

    for( int i = 0; i < n; i++ )
        T[i].output();

    return 0;
}

/*入力*/
void tuples::input( int v, int w, char t, unsigned long long d, string s )
{
    value = v;
    weight = w;
    type = t;
    date = d;
    name = s;
}

void tuples::output()
{
    cout << value << " " << weight << " " << type << " " << date << " " << name << endl;
}

/*マージソートで昇順に並べる。*/
void merge( tuples* x, int left, int mid, int right )
{
    int ls = mid - left;
    int rs = right - mid;

    tuples L[ls+1], R[rs+1];
    L[ls].input( 2000000000, 2000000000, '[', 3000000000000LL, "" );      //番兵の設定
    R[rs].input( 2000000000, 2000000000, '[', 3000000000000LL, "" );
    

    for( int i = 0; i < ls; i++ )
        L[i] = x[left+i];

    for( int i = 0; i < rs; i++ )
        R[i] = x[mid+i];

    int i = 0, j = 0;
    for( int k = left; k < right; k++ )
    {
        if( L[i].rv() < R[j].rv() )                             // 1. valueの比較
        {
            x[k] = L[i];
            i++;
        }
        else if ( L[i].rv() > R[j].rv() )                       // 1.
        {
            x[k] = R[j];
            j++;
        }
        else
        {
            if( L[i].rw() < R[j].rw() )                         // 2. weightの比較
            {
                x[k] = L[i];
                i++;
            }
            else if( L[i].rw() > R[j].rw() )
            {
                x[k] = R[j];
                j++;
            }
            else
            {
                if( L[i].rt() < R[j].rt() )                     // 3. typeの比較
                {
                    x[k] = L[i];
                    i++;
                }
                else if( L[i].rt() > R[j].rt() )
                {
                    x[k] = R[j];
                    j++;
                }
                else
                {
                    if( L[i].rd() < R[j].rd() )                 // 4. dateの比較
                    {
                        x[k] = L[i];
                        i++;
                    }
                    else if( L[i].rd() > R[j].rd() )
                    {
                        x[k] = R[j];
                        j++;
                    }
                    else
                    {
                        if( L[i].rn() <= R[j].rn() )            // 5. nameの比較
                        {
                            x[k] = L[i];
                            i++;
                        }
                        else
                        {
                            x[k] = R[j];
                            j++;
                        }
                    }
                }
            }
        }
    }
}

void mergeSort( tuples* x, int left, int right )
{
    if( left + 1 < right )
    {
        int mid = ( left + right ) / 2;
        mergeSort( x, left, mid );
        mergeSort( x, mid, right );
        merge( x, left, mid, right );
    }
}


Measured memory_bytes: 15584