
#include <iostream>
#include <list>
using namespace std;

struct Player;

void ordena(list<Player>& P, bool punts);

void mostra(list<Player>& L) {
   list<Player>::iterator it; 
   for (it = L.begin(); it != L.end(); it++) {
      cout << it->first << ' ' 
           << it->last << ' ' 
           << it->points << endl;
   }
   cout << endl;
}

int main() {
   Player p;
   list<Player> L;
   while (cin >> p.first >> p.last >> p.points) {
      L.push_back(p);
   }
   ordena(L, true);
   mostra(L);
   ordena(L, false);
   mostra(L);
}
