A higher resolution is required to access the IDE
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
Roll up your sleeves, it's time for a murder mystery! As head detective, you will find a series of clues leading to exactly one culprit. An elementary clue is a string like1.
2.
3.
Within each line, one and only one of the identified individuals or items was involved in the criminal act. The first set of evidence thus indicates that either
Your task is to determine which of the names within the first set is the culpable party.
Example
Suppose that there are six lines of evidence, including the three above. This means that either
4.
In each set, one of the clues is correct, and the others are not. For instance, if
5.
Now we put on our deductive hats. If the homicide happened in the
6.
We can already deduce from set 3 that the crime occurred in the
Input
Line 1: Two space-separated integers L for lines of evidence and N for number of suspects
Next L lines: A string evidence in the form of a set of elementary clues, comma-space separated
The first line of evidence consists of N clues listing every suspect.
Next L lines: A string evidence in the form of a set of elementary clues, comma-space separated
The first line of evidence consists of N clues listing every suspect.
Output
Line 1: The identified culprit from the first line of evidence
Constraints
1 ≤ L ≤ 250
N < 12
The problem constraints are satisfied by exactly one culprit.
N < 12
The problem constraints are satisfied by exactly one culprit.
Example
Input
6 2 Madame Turquoise, Reverend Crimson candlestick, noose, sword reading room, bedchamber Reverend Crimson, candlestick, reading room Madame Turquoise, noose, reading room Reverend Crimson, sword, bedchamber
Output
Madame Turquoise
A higher resolution is required to access the IDE