eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Incognito

Incognito

\includegraphics{https://static.e-olymp.com/content/d8/d8ad0915f524e4a2fc1f244694bca777cb7c2b97.jpg} Spies use attributes to disguise themselves to make sure that they are not recognized. For example, when putting on sunglasses, a spy suddenly looks completely different and cannot be recognized anymore. Every combination of attributes gives a different appearance, but not all combinations are possible. For example, a hat and a turban are both headgear and cannot be used at the same time. Given the list of available attributes, compute how many distinct disguises can be made. \InputFile On the first line one positive number: the number of test cases, at most \textbf{100}. After that per test case: \begin{itemize} \item one line with an integer \textbf{n} (\textbf{0} ≤ \textbf{n} ≤ \textbf{30}): the number of available attributes. \item \textbf{n} lines with two space-separated strings: the name and the category of the attribute. \end{itemize} All strings consist of at least \textbf{1} and at most \textbf{20} lowercase letters. Within a test case all names are distinct. \OutputFile Per test case: \begin{itemize} \item one line with an integer: the number of possible distinct disguises that can be made with the given attributes, such that at most one attribute from each category is used. \end{itemize}
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
2
3
hat headgear
sunglasses eyewear
turban headgear
3
mask face
sunglasses face
makeup face
Выходные данные #1
5
3
Источник The 2013 Benelux Algorithm Programming Contest, BAPC 2013