SP12367 TAP2012D - Designing T-Shirts

Description

\[The original version of this problem (in Spanish) can be found at \] Argentina's rugby is currently in one of its best moments of

Input Format

Each test case is described using three lines. The first line contains a single integer number **N**, indicating the number of players in each of the two teams (**1 ). The second line contains the surnames of the **N** players in the under-18 team, whereas the third line contains the surnames of the **N** players in the under-21 team. Each surname is a non-empty string of at most **100** uppercase letters. In each test case the total number of characters in the **2N** surnames is at most **10 $ ^{5} $** , and two or more players of the same or different teams may have the same surname.** The end of the input is indicated by a line containing the number **-1**.

Output Format

For each test case, you should print a single line containing an integer number, representing the maximum number of letters that can be imprinted on a set of **N** valid t-shirts to be used by both teams as explained in the problem statement.