Have you ever seen the manga "Death Note"?
In the series the shinigami (God of death) dropped the death notes to human
world, and people who uses it is referred to as "Killer".
There are two Killers (and also two Death Notes in their possession, one each).
They kill people using the Death Note with certain rules:
(In this problem the rule is conceptually the same with in the manga, with some
slight differences. Please only consider the rule mentioned in this problem.)
Now, given the list the two Killers plan to write on their note, respectively,
suppose below for the two Killers:
1. Writing one letter on the note takes one second exactly.
Skipping whitespaces takes no time.
2. Both Killers write sequentially, that is, they write in the order same as
given in the list, from top to bottom, left to right.
3. The two killer start writing name at the same time from the beginning of their list.
4. Regardless of whatever happens, they never changes plan and skip a name
(even if the person written is already killed).
5. Both their name did not appear in the list (and is thus irrelevant).
Please lists all the people killed and when they were killed,
in chronological order (i.e. in order of time), then lexicographical order.
The input first contains an integer T, indicating the number of testcases.
Each testcase contains two blocks, being the name list of the two killers, respectively. Each block is in the form of a list of names, where names are consecutive alphabetic characters in lowercase. The name list is then followed by a dash('-'), indicating the end of list.
Note that since whitespaces do not consume any time in writing, they can appear arbitrarily. (Of course not in between names).
T <= 100
number of names in each list is no more than 1000.
length of any name is no more than 15.
Output all the people killed and when they were killed,
in chronological order (i.e. in order of time), then lexicographical order.
Time is measured in seconds elapsed since beginning of writing.
Also, please follow each block of output by a dash('-'). No blank line is allowed.
3 a bc de - fg hi jk - aa aa aa - aa aa cc - abc d ee ee ff - ab cd ee ff ee g h -
a 41 fg 42 bc 43 hi 44 de 45 jk 46 - aa 46 cc 46 - ab 42 abc 43 cd 44 d 44 ee 48 ff 48 g 51 h 52 -
Migrated from old NTUJ.
kelvin
No. | Testdata Range | Score |
---|