#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define long long long
#define LF '\n'
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

struct Article {
  int v, w;
  char t;
  long d;
  string name;

  Article(): Article(0,0,0,0, "") {}

  Article(int v, int w, char t, long d, const string &name)
    : v(v), w(w), t(t), d(d), name(name) {}

  bool operator < (const Article &a) const {
    return
       (v != a.v) ? v < a.v
      :(w != a.w) ? w < a.w
      :(t != a.t) ? t < a.t
      :(d != a.d) ? d < a.d
      :name < a.name;
  }
};

istream& operator>> (istream &is, Article &a) {
  is >> a.v >> a.w >> a.t >> a.d >> a.name;
  return is;
}

ostream& operator<< (ostream &os, const Article &a) {
  os <<
    a.v << ' ' <<
    a.w << ' ' <<
    a.t << ' ' <<
    a.d << ' ' <<
    a.name;
  return os;
}

signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<Article> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());
  for (const auto &e : a) {
    cout << e << LF;
  }

  return 0;
}


