Given one known English sentence, one known French sentence and sentences each wholly in one language, minimize the number of words used in both.
Medium7GraphNo attempts yetTime limit5sMemory limit512 MBYoungsun'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.
The first line contains the number of test cases T. (1≤T≤25)
The first line of each test case contains the number of sentences N. (2≤N≤200) Each of the next N 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.
For each test case, print one line in the form Case #x: y, where x is the test case number starting from 1 and y is the smallest possible number of words that are both English and French.