import java.io.*;

public class Top2014 {
  // Parte a.-
  static void ordenarXcols(String[ ] a, int posini, int posfin,
                    int colini, int colfin) {
    for (int i= posini; i<=posfin; i++) {
      // Buscamos la posicion del minimo en a[i], a[i+1], ..., a[posfin]
      int k= i;
      for (int j= i+1; j<=posfin; j++) {
        String sj= a[j].substring(colini, colfin+1);
        String sk= a[k].substring(colini, colfin+1);
        if (sj.compareTo(sk)<0)
          k= j;
      }
      // intercambiamos a[i] con a[j]
      String aux= a[i];
      a[i]= a[k];
      a[k]= aux;
    }
  }
  // Parte b.-
  public static void main(String[] args) throws IOException {
    // Lee el archivo
    BufferedReader lect= new BufferedReader(new FileReader("notas.txt"));
    String[] lins= new String[200];
    int n= 0;
    while (true) {
      String lin= lect.readLine();
      if (lin==null)
        break;
      lins[n]= lin;
      n= n+1;
    }
    // el arreglo lins contiene todas las líneas del archivo
    // ordenamos por nota (columnas 30 a 31)
    ordenarXcols(lins, 0, n-1, 30, 31);
    // ordenamos los ultimos 20 (los mejores) por nombre (columnas 0 a 29)
    ordenarXcols(lins, n-20, n-1, 0, 29);
    // Desplegamos
    for (int i= n-20; i<n; i++)
      System.out.println(lins[i].substring(0, 30));
  }
}
