{"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\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eYou are given a string $$$a$$$, consisting of $$$n$$$ characters, $$$n$$$ is even. For each $$$i$$$ from $$$1$$$ to $$$n$$$ $$$a_i$$$ is one of \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e\u0027, \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eB\u003c/span\u003e\u0027 or \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eC\u003c/span\u003e\u0027.\u003c/p\u003e\u003cp\u003eA bracket sequence is a string containing only characters \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e)\u003c/span\u003e\". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e+\u003c/span\u003e\" between the original characters of the sequence. For example, bracket sequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e()()\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(())\u003c/span\u003e\" are regular (the resulting expressions are: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(1)+(1)\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e((1+1)+1)\u003c/span\u003e\"), and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e)(\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e)\u003c/span\u003e\" are not.\u003c/p\u003e\u003cp\u003eYou want to find a string $$$b$$$ that consists of $$$n$$$ characters such that: \u003c/p\u003e\u003cul\u003e \u003cli\u003e $$$b$$$ is a regular bracket sequence; \u003c/li\u003e\u003cli\u003e if for some $$$i$$$ and $$$j$$$ ($$$1 \\le i, j \\le n$$$) $$$a_i\u003da_j$$$, then $$$b_i\u003db_j$$$. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eIn other words, you want to replace all occurrences of \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e\u0027 with the same type of bracket, then all occurrences of \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eB\u003c/span\u003e\u0027 with the same type of bracket and all occurrences of \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eC\u003c/span\u003e\u0027 with the same type of bracket.\u003c/p\u003e\u003cp\u003eYour task is to determine if such a string $$$b$$$ exists.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u0026nbsp;— the number of testcases.\u003c/p\u003e\u003cp\u003eThen the descriptions of $$$t$$$ testcases follow.\u003c/p\u003e\u003cp\u003eThe only line of each testcase contains a string $$$a$$$. $$$a$$$ consists only of uppercase letters \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e\u0027, \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eB\u003c/span\u003e\u0027 and \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eC\u003c/span\u003e\u0027. Let $$$n$$$ be the length of $$$a$$$. It is guaranteed that $$$n$$$ is even and $$$2 \\le n \\le 50$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each testcase print \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\" if there exists such a string $$$b$$$ that: \u003c/p\u003e\u003cul\u003e \u003cli\u003e $$$b$$$ is a regular bracket sequence; \u003c/li\u003e\u003cli\u003e if for some $$$i$$$ and $$$j$$$ ($$$1 \\le i, j \\le n$$$) $$$a_i\u003da_j$$$, then $$$b_i\u003db_j$$$. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eOtherwise, print \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eYou may print every letter in any case you want (so, for example, the strings \u003cspan class\u003d\"tex-font-style-tt\"\u003eyEs\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eyes\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eYes\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e are all recognized as positive answer).\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\nAABBAC\nCACA\nBBBBAC\nABCA\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 testcase one of the possible strings $$$b$$$ is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(())()\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eIn the second testcase one of the possible strings $$$b$$$ is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e()()\u003c/span\u003e\".\u003c/p\u003e"}}]}