import java.io.*;
import hsa.Console;
import java.util.Arrays;


// The "Rhombus" class.
public class Quiz
{
    public static void main (String[] args) throws IOException
    {

	// Open up the input and output file for IO purpose
	FileReader inFile = new FileReader ("DATA1.txt");
	FileWriter outFile = new FileWriter ("OUT1.txt");

	// Link the input and output file for
	BufferedReader in = new BufferedReader (inFile);
	BufferedWriter out = new BufferedWriter (outFile);

	// String e;
	String line;
	String[] word = new String [5];
	String[] word2 = new String [5];
	String[] compare = new String [5];

	// Keep reading as long as not end of file (eof)

	word [0] = in.readLine ();
	word2 [0] = in.readLine ();
	compare [0] = word2 [0] + " " + word [0];
	word [1] = in.readLine ();
	word2 [1] = in.readLine ();
	compare [1] = word2 [1] + " " + word [1];
	word [2] = in.readLine ();
	word2 [2] = in.readLine ();
	compare [2] = word2 [2] + " " + word [2];
	word [3] = in.readLine ();
	word2 [3] = in.readLine ();
	compare [3] = word2 [3] + " " + word [3];
	word [4] = in.readLine ();
	word2 [4] = in.readLine ();
	compare [4] = word2 [4] + " " + word [4];

	Arrays.sort (compare);
	for (int count = 0 ; count < 5 ; count++)
	{
	    int space = compare [count].indexOf (' ');
	    out.write (compare [count].substring (space + 1));
	    out.newLine ();
	}
	out.flush ();
	out.close ();
    }
}


// main method
// End of Class



