#P1039. Detective Deduction

    ID: 12397 Type: Default 1000ms 256MiB

Detective Deduction

Detective Deduction

In this problem, Mingming is playing a deduction game inspired by the detective Conan. One of his classmates has been secretly chosen to be the culprit. Mingming asks each classmate for a testimony. The testimonies can only be one of the following five types:

Testimony Meaning
I am guilty. The speaker claims: I am the culprit.
I am not guilty. The speaker claims: I am not the culprit.
XXX is guilty. The speaker claims: XXX is the culprit. (XXX is a name)
XXX is not guilty. The speaker claims: XXX is not the culprit. (XXX is a name)
Today is XXX. The speaker claims: Today is XXX, where XXX is one of the seven days: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, or Sunday.

Other words appearing in a testimony should be ignored for the purpose of logical deduction.

Mingming knows that among his classmates, exactly N always lie and the rest always tell the truth. Note that if a person tells the truth then every testimony he makes must be true; if he is a liar then every testimony he makes is false. Also, note that if a person gives multiple testimonies, they must all have the same truth value under a consistent assignment.

Your task is to determine the unique culprit according to the testimonies. It is guaranteed that there is exactly one culprit satisfying the conditions.

Input Format: The first line contains an integer N, the number of liars. The second line contains an integer M, the number of testimonies. Each of the following M lines is in the format:

SpeakerName: Testimony

Each testimony is exactly one of the five forms described above. In testimonies of the form "XXX is guilty." or "XXX is not guilty.", XXX represents a classmate's name. In testimonies of the form "Today is XXX.", XXX will be one of the seven days.

Output Format: Output the name of the culprit.

inputFormat

The input begins with two integers on separate lines:

  1. An integer N denoting the number of liars.
  2. An integer M denoting the number of testimonies.

Then M lines follow, each in the format:

SpeakerName: Testimony

The testimony will be exactly one of the following forms:

  • I am guilty.
  • I am not guilty.
  • XXX is guilty. (XXX is a name)
  • XXX is not guilty. (XXX is a name)
  • Today is XXX. (XXX is one of the seven days)

It is guaranteed that the input is such that exactly one culprit can be deduced.

outputFormat

Output a single line containing the name of the culprit.

sample

1
3
Alice: I am guilty.
Bob: Alice is not guilty.
Charlie: Today is Monday.
Alice