{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e\u0026nbsp;\u0026nbsp;Every student needs help from getting new knowledge by asking questions. Surveys are suggesting that some similar questions are repeated frequently. So it will be nice to develop an automatic question-answering system to answer these questions. Your algorithm should not have any prior knowledge, but it must be able to read sentences and remember the mentioned facts. Whenever the question is asked about such a fact, the system has to answer it properly.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u0026nbsp;\u0026nbsp;The input consists of many dialogues.\u003cbr\u003e\u0026nbsp;\u0026nbsp;There is a single positive integer T on the first line of input. (T \u0026lt;\u003d 500, but note that 95% of them are relatively small) It denotes the number of following dialogues. Each dialogue includes one or more lines. Each line contains one sentence: either a statement or a question. Statements end with a dot character (.) while questions end with a question mark (?). There is one extra line after each dialogue. That line ends with an exclamation mark (!). The definitions of the statements and questions will be discussed later.\u003cbr\u003e\u003cbr\u003eSentences can contain words, spaces and punctuation characters. All words contain only Latin letters and are case-sensitive. Unlike the normal English writing rules, the first letter of a sentence should keep lowercase unless the first word itself should begin with a capital letter. There are no extra spaces between words. No word will have more than 10 characters. There will be at most 1000 lines per dialogue.\u003cbr\u003e\u003cb\u003eStatements\u003c/b\u003e\u003cbr\u003eEach statement has one of the following forms:\u003cbr\u003e\u003ci\u003e\u003cbr\u003enoun_phrase are noun_phrase.\u003cbr\u003enoun_phrase can verb_phrase.\u003cbr\u003eeverything which can verb_phrase can verb_phrase.\u003cbr\u003eeverything which can verb_phrase are noun_phrase.\u003cbr\u003e\u003c/i\u003e\u003cbr\u003enoun_phrase and verb_phrase are both single word. The meanings of the four forms are:\u003cbr\u003e\u003cbr\u003eA are B: If X is A, then X is B.\u003cbr\u003eA can B: If X is A, then X has the ability to B.\u003cbr\u003eeverything which can A can B: If X has the ability to A, X has the ability to B.\u003cbr\u003eeverything which can A are B: If X has the ability to A, X is B.\u003cbr\u003e\u003cbr\u003e\u003cb\u003eQuestions\u003c/b\u003e\u003cbr\u003eEach question has one of the following forms:\u003cbr\u003e\u003ci\u003e\u003cbr\u003eare noun_phrase noun_phrase?\u003cbr\u003ecan noun_phrase verb_phrase?\u003cbr\u003ecan everything which can verb_phrase verb_phrase?\u003cbr\u003eare everything which can verb_phrase noun_phrase?\u003cbr\u003e\u003c/i\u003e\u003cbr\u003e\u003cbr\u003eThey are the question form of the statements.\u003cbr\u003e\u003cbr\u003eIn each test case, the number of different noun phrases will not exceed 100; the number of different verb phrases will not exceed 100.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u0026nbsp;\u0026nbsp;For each test case, output two lines. The first line describes the test case number counting from 1, while the second line contains the same number of characters as the number of questions in this test case. Each character is either ‘Y’(denoting you can get that fact logically) or ‘M’(otherwise), without quotes."}},{"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\u003e1\r\nflies can fly.\r\nflies are insects.\r\neverything which can fly are animals.\r\nare everything which can fly insects?\r\nare flies animals?\r\ncan flies eat?\r\neverything which can fly can eat.\r\ncan flies eat?\r\nBye!\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\nMYMY\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}