Limits 1s, 512 MB

There will be a list of events and each event will contain a number of tasks.
Each event will have a unique name and a time which means when the event will be ready to execute. If two events are ready at the same time then they will be executed independently.

Each task of a event will have a unique name and required time to complete the task. Tasks will be executed in increasing order of the required time, if two tasks have same required time then they will be executed in alphabetical order of their name.

You will be given a time and you have to find the name of the event(s) and it's corresponding task name, those were executing at that time.

Input

First line of input will contain T (1 <= T <= 20) the number of testcases.
Each testcase will contain N (1 <= N <= 100) the number of Events. Next of the N lines will contain n the name of the event and t (1 <= t <= 1000) when the event will be ready to execute.
Each of the next N lines will contain a number m (1 <= m <= 100) which denotes the number of tasks of this event. Each of the next m lines will contain n the name of the task and p time required to complete the task.
Then you will be given a time Q, you have to find the name of the event(s) and it's corresponding task name, those were executing or completed at time Q.
Name of the events and tasks will contain only alphanumeric characters and their length will be maximum 100.

Output

For each testcase you have to print the name of the events in alphabetical order and their task name in a new line. If no event was executing at time Q just print "none".
Print a blank line after each test case.

Sample

InputOutput
3
2
Event1 3
Event2 4
1
Task1 2
1
Task1 1
3
2
Event1 3
Event2 4
1
Task1 2
1
Task1 1
5
2
Event1 3
Event2 4
1
Task1 2
1
Task1 1
1
Event1 Task1

Event1 Task1
Event2 Task1

none


Submit

Login to submit.

Statistics

56% Solution Ratio
YouKnowWhoEarliest, Apr '19
nusuBotFastest, 0.0s
Fuad_IslamLightest, 1.4 MB
ovis96Shortest, 1006B
Toph uses cookies. By continuing you agree to our Cookie Policy.