/ OPS / 题库 /

English is very important

English is very important

#描述#
As we all know, grammar is very important when learning English. In my mind, writing sentences is a good way to learn grammar. So I tell myself to write 200 sentences a day, using the word learned in the class. But after I end this work, I am very tired. I already have not the energy to check all the sentences. Now I ask you for help. You task is to write a program to check the sentences.
To make the work simple, I choose 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.
Here comes the sentence structure:
1. Subject + Intransitive Verb
2. Subject + Transitive Verb + Object
Noun 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's your time to show.

#格式#
##输入格式##
The input contains only one case.
The first line specifies two number N and M (1 ≤ N, M ≤ 200). The next N lines will be the words and the functions. Every line contains a word and its function, separated by a space. The next M 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.

##输出格式##
The output contains M lines. For each line, output "YES" if the sentence is OK, and output "NO" if not.

#样例1#
##样例输入1##

10 6
he pron.
see vt.
a art.
baby n.
at prep.
the art.
airport n.
happy adj.
guess v.
immediately adv.
He guess.
He see baby.
Happy he see a baby.
He immediately see a baby.
He see a baby immediately.
At the airport, he see a happy baby.

##样例输出1##

YES
NO
NO
YES
NO
YES

#限制#
1000ms
32768KB

#提示#
Please read the Problem Description carefully. Do not use your own English knowledge to construct rules.

#来源#

信息

ID
1761
难度
5
分类
category1 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者