1266: Jimmy‘s Riddles

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:0 解决:0

题目描述

Little Jimmy is only three years old but appears to be more intelligent than even Sir Isaac Newton at the age of three. People say that Jimmy could count up to ten when he was a child of ten months. His field of interest changes with his age and at present he is researching on how to trouble his mother scientifically. He has a book of 5000 riddles and applies them every now and then. For example, if his mother asks him - " Will you stop watching Tom and Jerry? " he will say - " tom hates jerry, jimmy hates tom" which means, " yes I will ". Obviously his mother is in all sorts of trouble. However, Jimmy is considerate. After all, he knows that his days will not be very smooth if he continues annoying his mother this way. So he taught her a number of ridiculous (riddle calculus) formulas so that she can quickly interpret Jimmys riddles. But, she was a student of history and doesnt know much about ridiculous formulas. So, you are to help her to get out of this trouble. You are to write a program that will read a number of riddles and, by using a number of ridiculous formulas, determine what they mean. The formulas are given below: · STATEMENT = ACTION | STATEMENT , ACTION · ACTION = ACTIVE_LIST VERB ACTIVE_LIST · ACTIVE LIST = ACTOR | ACTIVE_LIST and ACTOR · ACTOR = NOUN | ARTICLE NOUN · ARTICLE = a | the · NOUN = tom | jerry | goofy | mickey | jimmy | dog | cat | mouse · VERB = hate | love | know | like | VERBs If a riddle is a valid ridiculous calculus statement, it means YES I WILL; otherwise it means NO I WON‘T.

输入

The first line of input file contains T, the number of test cases. The following part contain a number of riddles each on a different line. Each riddle will consist of lowercase alphabetic characters and comma(s) only. The riddle may contain words not mentioned in the formulas. For each riddle, you are to determine what it means.

输出

For each riddle the output will be YES I WILL if the riddle is a valid ridiculous calculus statement and NO I WON‘T otherwise. The output for each riddle is to be on a separate line.

样例输入 复制

4
the dog and a cat know goofy
jimmy kills tom
goofy hate mouse jerry
tom hates jerry , jimmy hates tom

样例输出 复制

YES I WILL
NO I WON‘T
NO I WON‘T
YES I WILL