#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) rep(i,0,n)

int main()
{
    int n;
    cin>>n;
    vector<tuple<int,int,char,int64_t,string> >a(n,tuple<int,int,char,int64_t,string>());
    int v,w;
    char t;
    int64_t d;
    string s;
    REP(i,n)
    {
        cin>>v>>w>>t>>d>>s;
        a.at(i)=make_tuple(v,w,t,d,s);
    }
    sort(a.begin(),a.end());
    REP(i,n)cout<<get<0>(a.at(i))<<" "<<get<1>(a.at(i))<<" "<<get<2>(a.at(i))<<" "<<get<3>(a.at(i))<<" "<<get<4>(a.at(i))<<endl;
}
