11266 - Query products   

Description

Given a lot of product names and its price , you have to print out all the products which is beginning with the query string

from the lowest price to the highest price.

Note that :

1. All you have to do is to check whether the product name is beginning with the query string 

   If true , it's a match .  If not, it's not a match. 

   Ex: If the query string is "Apple" , then "AppleIphone7s" is a match and "SamsungNote7" isn't a match.

         Because "AppleIphone7s" is beginning with "Apple" , while "SamsungNote7" isn't.

2. Print out all the matches from the lowest price to the highest price.

3.There is at least 1 match in every test case.

4.The price of each product is different from others.

5. If you encounter TLE (Time Limit Exceed) , you can use "qsort" to speed up your program

 

 

Input

The first line contains an integer N , indicating the number of products. (2<=N<=100)

Each of the following N lines contains a product name and its price . (3<=length of name<=20)

The last line is the query string.

Output

Print out all the matches in this output format:

      printf("%s %d\n",product_name,price);

You should print out the matches from the lowest price to the highest price.

 

 

Sample Input  Download

Sample Output  Download

Tags




Discuss