{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003ePPAP, which stands for Pen Pineapple Apple Pen, is an unusual song and dance that went viral in the Internet recently. It\u0027s about merging a pen with either an apple or a pineapple, and then merging those together into more complicated structures.\u003c/p\u003e\u003cp\u003eA \u003cspan class\u003d\"tex-font-style-it\"\u003estructure\u003c/span\u003e is either one of mentioned items (a pen, an apple or a pineapple) or a result of combining two structures. In the former case we say a structure is \u003cspan class\u003d\"tex-font-style-it\"\u003ebasic\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eThe size of a basic structure is \u003cspan class\u003d\"tex-span\"\u003e1\u003c/span\u003e. The size of any other structure is equal to the sum of sizes of two structures merged into this one.\u003c/p\u003e\u003cp\u003eTwo structures can be merged if one of the following conditions holds true:\u003c/p\u003e\u003col\u003e \u003cli\u003e Both structures are basic and exactly one of them is a pen. \u003c/li\u003e\u003cli\u003e None of two structures are basic and their sizes are equal. \u003c/li\u003e\u003c/ol\u003e\u003cp\u003eA structure can be represented by a string of length equal to the size of the structure. A basic structure is represented by \u003cspan class\u003d\"tex-font-style-tt\"\u003e\"A\"\u003c/span\u003e (if it\u0027s an apple) or by \u003cspan class\u003d\"tex-font-style-tt\"\u003e\"P\"\u003c/span\u003e (if it\u0027s a pen or a pineapple). When a structure represented by a string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ew\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e\u003c/span\u003e and a structure represented by a string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ew\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e2\u003c/sub\u003e\u003c/span\u003e are merged together, they create a structure represented by a string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ew\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e\u003ci\u003ew\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e2\u003c/sub\u003e\u003c/span\u003e (strings are concatenated). The order of two merged structures matters because \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ew\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e\u003ci\u003ew\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e2\u003c/sub\u003e\u003c/span\u003e may be different that \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ew\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e2\u003c/sub\u003e\u003ci\u003ew\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eYou are given \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eT\u003c/i\u003e\u003c/span\u003e test cases, each with one string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e consisting of characters \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027A\u0027\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027P\u0027\u003c/span\u003e. Your task is to check whether it\u0027s possible to get a structure represented by such a string. Print \u003cspan class\u003d\"tex-font-style-tt\"\u003e\"YES\"\u003c/span\u003e or \u003cspan class\u003d\"tex-font-style-tt\"\u003e\"NO\"\u003c/span\u003e in a separate line, without the quotes.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of the input contains an integer \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eT\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003eT\u003c/i\u003e ≤ 10\u003c/span\u003e)\u0026nbsp;— the number of test cases.\u003c/p\u003e\u003cp\u003eEach of the next \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eT\u003c/i\u003e\u003c/span\u003e lines contains one string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ |\u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e| ≤ 100\u003c/span\u003e), describing one test case. A string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e consists of characters \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027A\u0027\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0027P\u0027\u003c/span\u003e only.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case in a separate line print \u003cspan class\u003d\"tex-font-style-tt\"\u003e\"YES\"\u003c/span\u003e (without the quotes) if it\u0027s possible to get a structure represented by the given string, and \u003cspan class\u003d\"tex-font-style-tt\"\u003e\"NO\"\u003c/span\u003e otherwise (without the quotes).\u003c/p\u003e"}},{"title":"Examples","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\u003e4\nPPAP\nA\nAAAA\nPPAPP\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nYES\nNO\nNO\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first test case, one valid way is to merge a pen and a pineapple to get \u003cspan class\u003d\"tex-font-style-tt\"\u003e\"PP\"\u003c/span\u003e, then merge an apple and a pen to get \u003cspan class\u003d\"tex-font-style-tt\"\u003e\"AP\"\u003c/span\u003e, and finally merge two created structured in the order (\u003cspan class\u003d\"tex-font-style-tt\"\u003e\"PP\"\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003e\"AP\"\u003c/span\u003e). The final structure is represented by \u003cspan class\u003d\"tex-font-style-tt\"\u003e\"PPAP\"\u003c/span\u003e, as required.\u003c/p\u003e"}}]}