{"raw_statement":[{"iden":"statement","content":"Mr. Light found that some colors appear more than others, and sometimes, many balloons of the same color are adjacent. He doesn't want to cut the rope and reorder them, instead, he's going to use special light sources.\n\nThe color of the balloon changes the first time it is in the range of a light source. Red balloons become blue, green balloons become red, and blue balloons become green.\n\nAfter the first light source hits it, the color of the balloon never changes again -it will stay in its new color even if another light source hits it. More formally, the color of the balloon changes at most once.\n\nMr. Light will start turning some lights on, one by one. Each time he wants to know for each color the number of balloons with that color.\n\nThe first line of input contains two space-separated integers N, M (1 ≤ N ≤ 2 × 105) , the number of balloons and the number of light sources Mr. Light will turn on.\n\nThe second line of input contains a string S of length N, representing the balloons in the line. Each letter is either 'R', 'G', or 'B' and represents the color of that balloon.\n\nEach of the following M lines contains two space-separated integers l, r (1 ≤ l ≤ r ≤ N), representing the range of a light source.\n\nPrint M lines, the Kth line contains three integers R G B, each integer is equal to the number of balloons that appear in that color after turning on the first K light sources.\n\n"},{"iden":"input","content":"The first line of input contains two space-separated integers N, M (1 ≤ N ≤ 2 × 105) , the number of balloons and the number of light sources Mr. Light will turn on.The second line of input contains a string S of length N, representing the balloons in the line. Each letter is either 'R', 'G', or 'B' and represents the color of that balloon.Each of the following M lines contains two space-separated integers l, r (1 ≤ l ≤ r ≤ N), representing the range of a light source."},{"iden":"output","content":"Print M lines, the Kth line contains three integers R G B, each integer is equal to the number of balloons that appear in that color after turning on the first K light sources."},{"iden":"examples","content":"Input8 4RRGRGRRB1 35 82 22 7Output4 1 33 1 43 1 42 1 5Input6 3RGRGBB1 32 42 5Output1 1 42 0 42 1 3"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ N, M \\in \\mathbb{Z}^+ $ denote the number of balloons and light sources, respectively.  \nLet $ S = s_1 s_2 \\dots s_N \\in \\{R, G, B\\}^N $ be the initial color sequence of the balloons.  \nLet $ L_k = [l_k, r_k] $ for $ k \\in \\{1, \\dots, M\\} $ denote the range of the $ k $-th light source.  \n\nLet $ C_k : \\{1, \\dots, N\\} \\to \\{R, G, B, \\text{changed}\\} $ be the color state of balloon $ i $ after the first $ k $ light sources have been activated, where:  \n- Initially, $ C_0(i) = s_i $.  \n- For $ k \\geq 1 $, if $ i \\in L_k $ and $ C_{k-1}(i) \\notin \\{\\text{changed}\\} $, then:  \n  $$\n  C_k(i) = \n  \\begin{cases}\n  B & \\text{if } C_{k-1}(i) = R \\\\\n  R & \\text{if } C_{k-1}(i) = G \\\\\n  G & \\text{if } C_{k-1}(i) = B \\\\\n  \\end{cases}\n  $$  \n  Otherwise, $ C_k(i) = C_{k-1}(i) $.  \nOnce changed, $ C_k(i) $ remains fixed for all future $ k' > k $.  \n\n**Constraints**  \n1. $ 1 \\leq N \\leq 2 \\times 10^5 $  \n2. $ 1 \\leq M \\leq 2 \\times 10^5 $  \n3. $ 1 \\leq l_k \\leq r_k \\leq N $ for all $ k \\in \\{1, \\dots, M\\} $  \n\n**Objective**  \nFor each $ k \\in \\{1, \\dots, M\\} $, compute:  \n$$\nR_k = |\\{ i \\in \\{1, \\dots, N\\} \\mid C_k(i) = R \\}|, \\quad\nG_k = |\\{ i \\in \\{1, \\dots, N\\} \\mid C_k(i) = G \\}|, \\quad\nB_k = |\\{ i \\in \\{1, \\dots, N\\} \\mid C_k(i) = B \\}|\n$$  \nOutput $ (R_k, G_k, B_k) $ for each $ k $.","simple_statement":"You are given N balloons in a line, each colored R, G, or B.  \nYou have M light sources. Each light covers a range [l, r].  \n\nWhen a balloon is first hit by any light, its color changes:  \n- R → G  \n- G → B  \n- B → R  \n\nAfter changing once, the color stays fixed — even if hit again.  \n\nAfter each light is turned on (one by one), output the current count of R, G, and B balloons.","has_page_source":false}