{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv\u003e\u003cp\u003eAs we all know, grammar is very important when learning English. Now, YYF become a teacher of a primary school. The students are good at memory so they can tell the meaning and the function (noun, verb …) of the words in the textbook. But, they cannot use these words properly.\u003c/p\u003e\u003cp\u003eIn YYF’s mind, writing sentences is a good way to learn grammar. So he tells the student to write 20 sentences a day, using the word learned in the class. As YYF has a lot of student, he will receive many sentences from his student. What a horrible work to check all the sentences. You are one of YYF’s friends, so he asks you for help. You task is to write a program to check the sentences. \u003c/p\u003e\u003cp\u003eTo make the work simple, YYF chooses a part of the grammar: All the words can be grouped into seven divisions (noun, pronoun, adjective, adverb, preposition, article, and verb). A verb can be transitive or intransitive. So we use \"n.\", \"pron.\", \"adj.\", \"adv.\", \"prep.\", \"art.\", \"vt.\" and \"vi.\" to be short of noun, pronoun, adjective, adverb, preposition, article, transitive verb and intransitive verb. If a word is marked as \"v.\", it can be used as either transitive verb or intransitive verb. \u003c/p\u003e\u003cp\u003eHere comes the sentence structure:\u003cbr\u003e1.\tSubject + Intransitive Verb\u003cbr\u003e2.\tSubject + Transitive Verb + Object\u003cbr\u003e\u003c/p\u003e\u003cp\u003eNoun and pronoun can be used as Subject or Object. When using a noun, an article should be placed ahead of it. A noun can be modified by an adjective and a verb can be modified by an adverb. When an adjective is used to modify a noun, it should be put between article and noun. When an adverb is used to modify a verb, it should be put ahead of the verb. A prepositional phrase can be put ahead of Subject, between Subject and Verb, behind Intransitive Verb, between Verb and Object, or behind Object. A prepositional phrase is made up of a preposition and a noun/pronoun. In one sentence, at most one prepositional phrase is allowed. Any two parts of the sentence cannot intersect. For example, \"He is a good student\" is OK, but \"He a good is student\" is not. Every word in the dictionary will have only one function. The words are not case sensitive and Subject-Verb Agreement does not matter. That’s all the rules. Now, it\u0027s your time to show. \u003c/p\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv\u003eThe input contains only one case.\u003cbr\u003eThe first line specifies two number \u003ci\u003eN\u003c/i\u003e and \u003ci\u003eM\u003c/i\u003e (1 ≤ \u003ci\u003eN\u003c/i\u003e, \u003ci\u003eM\u003c/i\u003e ≤ 5000). The next \u003ci\u003eN\u003c/i\u003e lines will be the words and the functions. Every line contains a word and its function, separated by a space. The next \u003ci\u003eM\u003c/i\u003e lines will be the sentences -- one sentence per line. Each sentences contains at most 20 words. Every word in the sentences will appear in the dictionary. \u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv\u003eThe output contains \u003ci\u003eM\u003c/i\u003e lines. For each line, output \"YES\" if the sentence is OK, and output \"NO\" if not. \u003c/div\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e10 6\r\nhe pron.\r\nsee vt.\r\na art.\r\nbaby n.\r\nat prep.\r\nthe art.\r\nairport n.\r\nhappy adj.\r\nguess v.\r\nimmediately adv.\r\nHe guess.\r\nHe see baby.\r\nHappy he see a baby.\r\nHe immediately see a baby.\r\nHe see a baby immediately.\r\nAt the airport, he see a happy baby.\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\r\nNO\r\nNO\r\nYES\r\nNO\r\nYES\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"Please read the Problem Description carefully. Do not use your own English knowledge to construct rules."}}]}