#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int	N;
	cin >> N;
	vector<tuple<int, int, char, int64_t, string>> vec;
	rep(i, N)
	{
		int		a, b;
		char	c;
		int64_t	d;
		string	s;
		cin >> a >> b >> c >> d >> s;
		vec.push_back(make_tuple(a, b, c, d, s));
	}
	sort(vec.begin(), vec.end());
	for (auto t : vec)
	{
		int		a, b;
		char	c;
		int64_t	d;
		string	s;
		tie(a, b, c, d, s) = t;
		cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << s << endl;
	}
}

