The problem is that in the movie about 10 male and 10 female characters occur, and -- with the tiny budget that you have been given -- you simply cannot afford that many actors and actresses!
Looking closely at the movie script, however, you wonder if some of the characters could be played by the same person. For example, if Mr. Programmer and Mr. Hero never appear together at the same time during the movie, one actor can play both roles!
You tell your boss your idea, and he agrees, as long as you adhere to the following rules:
Given these restrictions, your job is to determine the minimum number of actors and actresses needed to produce the movie.
The input consists of several movie descriptions. Each description starts with one line that contains three integers M, F, S that specify the number of male (1 ¡Ü M ¡Ü 10) and female (1 ¡Ü F ¡Ü 10) characters occurring in the movie and the number of scenes that the movie has (1 ¡Ü S ¡Ü 100).
On the second and third line, the names of the male and female characters are given. No two persons have the same name. A name consists of less than 30 alphabetic letters with no white space in between.
Then S lines follow, each line describing one scene. Each of these lines contains the number of people who occur in the scene and the list of their names.
The input is terminated by a test case with M = F = S = 0. This test case should NOT be processed.
For each movie description, output three lines:
See the sample output below for the correct output format.
1 1 1 Donald Esther 2 Donald Esther 4 3 6 Tarzan Jim John Tom Lucy Cynthia Jane 3 Jim John Tom 2 Tarzan Lucy 2 Jane Cynthia 2 Jim Jane 2 Tarzan Jim 2 Tarzan Jane 0 0 0Sample Output
Movie #1 You need 1 actor and 1 actress. Movie #2 You need 3 actors and 2 actresses.