本站作为LDUOnlineJudge的测试版本进行演示,官方网站请访问http://icpc.ldu.edu.cn
[Hidden]

1227. G. Brett Favre Diaries


Description

The sporting world recently underwent a media overload with the Brett Favre story. The record-breaking Green Bay Packers quarterback, after initially deciding to retire in March, had second thoughts about his decision in the summer. Had Green Bay simply let Brett join the team again, this would not have been much of a story. But, the real saga was quite a bit more complicated. As everyone knows, the media tends to pick individual stories and follows them to no end, much like the O.J. Simpson trial coverage. ESPN treated the Brett Favre story with the same diligence.

You are a football fan and are interested in the Favre story, but enough is enough. You are sick and tired of getting insignificant updates such as, "Brett Favre eats hot dog" on your cell phone. You want to write a program for your cell phone so that it filters Brett Favre news and only reports to you important information, namely whenever he travels to a new city.

The Problem:

Given a list of cities, and a log of chronological information (with a date and time) about Brett Favre, isolate the log entries that contain the name of a city (from the list of cities) different from the city mentioned in the previous log entry with a city. You will be guaranteed that the very first item in the log will contain the name of a city. From that point on, a new log entry is only printed if it contains the name of a city DIFFERENT than the previous log entry with a city (note that the "previous log entry with a city" may not be the "immediate previous log entry"). Your job will simply be to print out the lines of the log that should be presented on the cell phone text feed.

Note: A city is only considered to be in a log entry if it appears EXACTLY, character by character, in the log entry. Namely, capitalization has to match as well as all non-letter characters. However, for our comparison purposes, if the city name is (say) AB and the log entry contains (say) CABD, then the log contains the city, i.e., there doesn't have to be space or punctuation mark before/after the city name in the log.

Input

There will be multiple news scenarios (test cases). The first line of the input contains a positive integer n, representing the number of news scenarios to filter. Each scenario follows. The first line of each test case contains a positive integer, m(1m50), which represents the number of cities for the test case. The following mm lines contain the names of the cities, one per line. These names may contain letters, digits, commas, and spaces (assume no leading or trailing spaces). These input lines (city names) will each be at most 30 characters and will contain at least one non-blank character. Assume that the words Brett and Favre (in any form of upper/lower case) will not be in any city name. Also assume that no city name will be a substring of another city name within a test case. The next input line after the city names will contain another positive integer, k(1k100), representing the number of log entries for this case. The next k lines contain one log entry each, given in chronological order (i.e., you don't need to sort them based on date/time). The log entries can contain any printable characters but will not exceed 100 characters each. Assume that a log entry contains at most one city name.

Output

At the beginning of each test case, output "Brett Log #p:", on a ine by itself, where pp is the test case number (starting from 1). The following lines should simply contain, in order, the lines from the entry log that are significant, according to the given criteria.

Leave a blank line after the output for each test case. Follow the format illustrated in Sample Output.

Samples

Input Copy
2
4
Green Bay
Hattiesburg
New York
Cleveland, Ohio
7
7/23 5:00 PM: Brett leaves Hattiesburg in private plane.
7/23 5:10 PM: Brett eats breakfast omelet on plane.
7/23 5:20 PM: Did I mention Brett is leaving Hattiesburg?
7/23 5:30 PM: Brett falls asleep on plane.
7/23 7:45 PM: Brett lands in Green Bay to waiting fans.
7/23 8:15 PM: Brett watches Packers practice.
7/23 8:20 PM: Deanna is watching practice as well.
2
Cleveland, Ohio
New York
5
7/25 10:00 AM: Brett arrives in New York.
7/25 11:00 AM: Brett does press conference in New York.
7/25 1:25 PM: Brett flies to Cleveland, Ohio.
7/25 4:45 PM: Brett does press conference in Cleveland, Ohio.
7/25 6:00 PM: Brett walks onto field in Cleveland, Ohio.
Output
Brett Log #1:
   7/23 5:00 PM: Brett leaves Hattiesburg in private plane.
   7/23 7:45 PM: Brett lands in Green Bay to waiting fans.

Brett Log #2:
   7/25 10:00 AM: Brett arrives in New York.
   7/25 1:25 PM: Brett flies to Cleveland, Ohio.

Source

UCF Practice 2013
Problem Information

Time Limit: 1000MS (C/C++,Others×2)
Memory Limit: 256MB (C/C++,Others×2)
Special Judge: No
AC/Submit: 1 / 1
Tags:
Contests involved

1026. UCF 2013 Practice
My history solutions

You didn't submit any solution!
Submit your solution

Login Register