#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const int BITSIZE = 100010;

struct Less {
	bool operator()(const tuple<ll, ll, string, ll, string>& x, const tuple<ll, ll, string, ll, string>& y) const {
        if(get<0>(x)==get<0>(y)){
            if(get<1>(x)==get<1>(y)){
                if(get<2>(x)==get<2>(y)){
                    if(get<3>(x)==get<3>(y)){
                        return get<4>(x) < get<4>(y);
                    }else return get<3>(x) < get<3>(y);
                }else return get<2>(x) < get<2>(y);
            }else return get<1>(x) < get<1>(y);
        }else return get<0>(x) < get<0>(y);
            
	}
};
void print_vector(vector<tuple<ll, ll, string, ll, string> >& v)
{
    for(auto& element : v){
        cout << get<0>(element) << " " << get<1>(element) << " " << get<2>(element) << " " << get<3>(element) << " " << get<4>(element)  << endl;
    }
    
}


vector<tuple<ll, ll, string, ll, string> > v;
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    REP(i, n) {
        ll vv, w, d; string t, s;
        cin >> vv >> w >> t >> d >> s;
        tuple<ll, ll, string, ll, string> tu = make_tuple(vv, w, t,d,s);
        v.push_back(tu);
    }
    sort(v.begin(), v.end(), Less());
    
    
    print_vector(v);
	return 0;
}
