{"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 $$$S$$$ of length $$$3n$$$, consisting of the characters \u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eB\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003eC\u003c/span\u003e. You are allowed to perform the following operation:\u003c/p\u003e\u003cul\u003e\u003cli\u003e Select some subsegment of this string and a character $$$c$$$ (one of \u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eB\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003eC\u003c/span\u003e). Then, replace all the characters on the subsegment with $$$c$$$.\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFind the smallest number of times that you would have to apply the operation above to get a string which contains each of characters \u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eB\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003eC\u003c/span\u003e exactly $$$n$$$ times. It can be shown that it is always possible to get such a string.\u003c/p\u003e\u003cp\u003eIn addition, find a sequence of operations of the smallest possible length. If there are many such sequences, you can output any of them.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of input contains a single integer $$$n$$$ ($$$1 \\le n \\le 3 \\cdot 10^5$$$).\u003c/p\u003e\u003cp\u003eThe second line of the input contains a string $$$S$$$ of length $$$3n$$$, consisting of the characters \u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eB\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003eC\u003c/span\u003e.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eIn the first line print the minimum number of operations $$$k$$$.\u003c/p\u003e\u003cp\u003eIn the $$$i$$$-th of the next $$$k$$$ lines print $$$2$$$ integers $$$l_i, r_i$$$ and a character $$$c_i$$$ ($$$1 \\le l_i \\le r_i \\le 3n$$$, $$$c_i \\in \\{\\texttt{A}, \\texttt{B}, \\texttt{C}\\}$$$), denoting that in the $$$i$$$-th operation you will replace each of the characters $$$S_{l_i}, S_{l_i+1}, \\ldots, S_{r_i}$$$ with $$$c_i$$$.\u003c/p\u003e\u003cp\u003eIf there is more than one solution with a minimum number of operations, you can print any one of them.\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\u003e1\nAAA\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n2 3 B\n3 3 C\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","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\nCAB\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","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\u003e3\nABABCABAB\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n1 2 C\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 sample, the string will undergo the following transformations:\u003c/p\u003e\u003cp\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003eAAA\u003c/span\u003e $$$\\to$$$ \u003cspan class\u003d\"tex-font-style-tt\"\u003eABB\u003c/span\u003e $$$\\to$$$ \u003cspan class\u003d\"tex-font-style-tt\"\u003eABC\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eIn the second sample, the string already contains exactly one \u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e, one \u003cspan class\u003d\"tex-font-style-tt\"\u003eB\u003c/span\u003e and one \u003cspan class\u003d\"tex-font-style-tt\"\u003eC\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eIn the third sample, the string will undergo the following transformation:\u003c/p\u003e\u003cp\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003eABABCABAB\u003c/span\u003e $$$\\to$$$ \u003cspan class\u003d\"tex-font-style-tt\"\u003eCCABCABAB\u003c/span\u003e. Now, it contains each letter $$$3$$$ times.\u003c/p\u003e"}}]}