STUDID - Students Database

You have to take name, roll number and age of N students.

Then take a surname as input and output the roll number of all the students that have that surname.

(Try Solving this with the help of struct. It is for learning.)

Input

First line contains the number of test cases T. (1 <= T <= 50)

First line of every test case contains an integer N, the number of students. (1 <= N <= 100).

For the N students there are 3 lines each containing their:

  • Name - String which has length less than 100. It will contain only [A-Z, a-z, space].
  • Roll Number - Integer with value between [1, 1000000]
  • Age - Integer with value between [1, 150]

Last line of each test case will have a string surname which has length less than 100. It will contain only [A-Z, a-z].

Output

For every test case print the roll numbers of all the student who share the surname in order of their input.

Print these in separate lines.

Example

Input:
1
3
Rajesh kumar
79
21
Sandesh kumar
86
21
Akashdeep Saluja
5
21
kumar

Output:
79
86

Added by:Rajesh Kumar
Date:2014-08-30
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.