The term "code monkey" is sometimes used for a programmer who does not know much about programming. This is unfair to monkeys: contrary to popular belief, monkeys are quite smart — they have simply been misunderstood. Perhaps this is because monkeys do not speak English, only monkey language. Your job is to help humans and monkeys understand each other by building a monkey-language dictionary: for each word you are given, decide whether it is a valid monkey-language word.
Spelling in monkey language is very simple. A string is a monkey-language word if and only if it can be built with the following rules:
N and another monkey-language word.A, or the letter B followed by a monkey-language word followed by the letter S.For example:
A is a monkey-language word because it is an A-word.ANA is a monkey-language word: the A-word A, then N, then the monkey-language word A.ANANA is a monkey-language word: the A-word A, then N, then the monkey-language word ANA.BANANAS is a monkey-language word: it is an A-word, namely B followed by the monkey-language word ANANA followed by S.Each line contains one word made of uppercase letters. Reading stops at the word X; X itself is not a monkey-language word and produces no output.
For each word before X, print YES if it is a valid monkey-language word, or NO if it is not, one answer per line.