#include <iostream>
#include <string>
#include <tuple>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n,x1,x2;
  long x4;
  char x3;
  string x5;
  vector<tuple<int, int, char, long, string>> a;

  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> x1;
    cin >> x2;
    cin >> x3;
    cin >> x4;
    cin >> x5;
    a.push_back(make_tuple(x1, x2, x3, x4, x5));
  }
  sort(begin(a), end(a));
  for (int i = 0; i < a.size(); i++)
          cout << get<0>(a[i]) << " "
               << get<1>(a[i]) << " "
               << get<2>(a[i]) << " "
               << get<3>(a[i]) << " "
               << get<4>(a[i]) << "\n";

  return 0;
}

