Limits 1s, 512 MB

We all know how great of a detective Sherlock Holmes is. However, suddenly he's stuck in a rather odd case.

There was a murder, and upon investigation, Sherlock noticed that the victim had scratched the floor with her nails and tried to write something. As he is a great detective, it didn't take much time for him to understand that she tried to write the name of the killer. Unfortunately, the killer noticed her actions. Before she could finish writing the name, he killed her. Upon further investigation, Sherlock found some blood under the victim's nails.

Now he has two leads: a partial name of the killer and the blood type of the killer. Sherlock came to a solution that he will check all the people there and categorize them into three categories:

  1. Suspected: A person is considered suspected if and only if the partial name exists in his/her name.

  2. Guilty: A person will be considered guilty if he/she is already suspected and his/her blood type also matches.

  3. Not guilty: A person will be proven not guilty otherwise.

Due to the numerous individuals present at the time of the murder, categorizing them is a heavy computational task. Sherlock Holmes has gathered the names and blood types of all individuals present at the crime scene. Now, as a young programmer, Sherlock Holmes seeks your help to categorize them.


The first line contains a single integer n(2n10)n \: (2 \leq n \leq 10) — the length of the fractional part.

The second line contains two strings, SS of size nn and BB representing the fractional part and blood type. There can be only six types of blood: A+A+, AA-, B+B+, BB-, O+O+, and OO-.

The third line consists of two integers ll and QQ (3l50,2Q1000)(3 \leq l \leq 50, \: 2 \leq Q \leq 1000) — the length of people's names and the number of people respectively. The length of names is consistent for all individuals.

The next QQ lines contain two strings SniSn_i and BtiBt_i (1iQ)(1 \leq i \leq Q) indicating the name and blood type of the person respectively.

Note that names are case sensitive meaning “Abid” and “abid” will be considered different.


For each person, print “Suspected” or “Guilty” or “Not guilty” accordingly.

Check sample cases to understand better.


caca B-
10 4
bcbccbaabc B-
bbbccaabbc B-
bcacabcaaa O+
acabacbccb B+
Not guilty
Not guilty
Not guilty
ac B+
3 8
cba O-
cab A+
baa O+
abc O-
cac O+
aab B+
bcc B+
acb B+
Not guilty
Not guilty
Not guilty
Not guilty
Not guilty
Not guilty

Be careful about the newline(‘\n’) at the end.


Login to submit.


100% Solution Ratio
sourov.cseEarliest, 5M ago
munyim.3725Fastest, 0.0s
Rakin.1859Lightest, 5.9 MB
Shahriar.888Shortest, 628B
Toph uses cookies. By continuing you agree to our Cookie Policy.