import java.io.*;
import java.util.*;

public class Kill
{
    public static void main (String[] args) throws IOException
    {
	BufferedReader in = new BufferedReader(new FileReader("DATA2.txt"));
	PrintWriter out = new PrintWriter(new FileWriter("OUT2.txt"));
	String temp, name;
	int kill, process;
	
	while (in.ready())
	{
	    temp = in.readLine ();
	    kill = Integer.parseInt(temp.substring(6));
	    for (int j = 1; j<=5; j++)
	    {
		temp = in.readLine ();
		StringTokenizer space2 = new StringTokenizer(temp);
		name = space2.nextToken ();
		process = Integer.parseInt (space2.nextToken ());
		if (process > kill)
		{
		    out.println (name);
		}
	    }
	    
	}
	
	out.close ();
    } // main method
} // Diff class

