import java.util.*;
import java.io.*;
/**
 * Write a description of class Problem1 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Prob1
{
    



    
    public static void main (String args[]) throws IOException
    {
        Scanner kb = new Scanner( new File("DATA1.txt"));
        PrintWriter xyz = new PrintWriter (new BufferedWriter (new FileWriter("OUT1.txt")));
       
        //ArrayLsi questions =  new String[];
        String[] nums = new String[5];
        //int[] nums= new int[15];
        
        for (int y=0;y<5;y++)
        {
            String temp = kb.nextLine();
            int num = Integer.parseInt(kb.nextLine());
            
            nums[num-1] = temp;
        }
       for ( int x=0; x<5;x++)
       {
           xyz.println(nums[x]);
       }
       
       xyz.close();
    }
       
    
}

