As director of the upcoming blockbuster movie SCU's Brilliancy, your employer Wang Shuguo has assigned you the task of selecting the actors and actresses.

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:

  1. Male characters can only be played by male actors, and female characters can only be played by female actresses.
  2. Each character must be played by one actor/actress throughout the whole movie. Changing the person who plays a given character during the movie is not allowed.
  3. When two characters ever appear together at the same time during the movie, they must be played by different actors/ actresses.

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.

Sample Input

1 1 1
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 0
Sample Output
Movie #1
You need 1 actor and 1 actress.

Movie #2
You need 3 actors and 2 actresses.