Under construction

Still being built. Things may change

English and French (Large)

Time limit5sMemory limit512 MB

Summary
Given one known English sentence, one known French sentence and sentences each wholly in one language, minimize the number of words used in both.
Level

Medium7 of 10

Topics
Graph
Solved
No attempts yet

Problem

Youngsun's parents speak to her at home in a mix of English and French. She has heard a great many words, but she does not know which of them are English and which are French.

Youngsun knows one sentence that is entirely English and one sentence that is entirely French. She also knows several sentences whose language she cannot tell. Each of those sentences is entirely English or entirely French.

If a word appears in an English sentence, that word is English. If a word appears in a French sentence, that word is French. One word can be English and French at the same time.

Given every sentence Youngsun heard, write a program that finds the smallest possible number of words that are both English and French.

Input

The first line contains the number of test cases TT. (1≤T≤251 \le T \le 25)

The first line of each test case contains the number of sentences NN. (2≤N≤2002 \le N \le 200) Each of the next NN lines contains one sentence.

A sentence is made of words separated by spaces. Every word consists of lowercase letters only, and its length does not exceed 10.

The first sentence is the English sentence and the second sentence is the French sentence. The language of the remaining sentences is unknown.

Each of the first two sentences has at most 1,000 words, and each of the remaining sentences has at most 10 words.

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 1 and yy is the smallest possible number of words that are both English and French.

Examples1

  1. Example 1

    Input
    4
    2
    he loves to eat baguettes
    il aime manger des baguettes
    4
    a b c d e
    f g h i j
    a b c i j
    f g h d e
    4
    he drove into a cul de sac
    elle a conduit sa voiture
    il a conduit dans un cul de sac
    il mange pendant que il conduit sa voiture
    6
    adieu joie de vivre je ne regrette rien
    adieu joie de vivre je ne regrette rien
    a b c d e
    f g h i j
    a b c i j
    f g h d e
    
    Expected output
    Case #1: 1
    Case #2: 4
    Case #3: 3
    Case #4: 8