Spinner (Large)

Given a circular row of R, G, B cells and a three-cell local update rule, count each color after K synchronous rounds with K up to 1e9.

Medium7SimulationMathNo attempts yetTime limit1sMemory limit256 MB

Problem

Jihun prepared a spinner for a prize event. The circular board is divided into NN equal parts, and each part is painted red, green, or blue. A participant picks one of the three colors. The board is spun, and everyone whose color matches the color of the part the spinner stops on receives a prize. If aa of the NN parts are red, bb are green and cc are blue, then the chance of each color is a/Na/N, b/Nb/N and c/Nc/N. So if nobody knows which part carries which color, all three colors are equally likely.

Jihun checked which colors the participants had picked and found that one of the three colors was picked far more often. The reason was that someone had looked at the spinner and told a few acquainted participants which color covered the most parts. Jihun therefore wants to repaint the whole board.

Number the parts 1 to NN clockwise. The left part of part ii is part i1i-1 and the right part is part i+1i+1, where the left part of part 1 is part NN and the right part of part NN is part 1.

One round of repainting works as follows. Every part changes color at the same time, and for each part PP you look at the three colors painted on the left part of PP, on PP itself, and on the right part of PP.

  1. If the three colors are all the same or all different, repaint PP blue.
  2. Otherwise two of the three parts carry color XX and the remaining one carries a different color YY.
  3. If (X,Y)(X, Y) is (red, green), (green, blue) or (blue, red), repaint PP red. Otherwise repaint it green.

Jihun repeated this round KK times in total. Find how many parts carry each color after the KK rounds.

Input

The first line contains NN and KK, separated by a space.

The second line contains a string of length NN that lists the color painted on every part, starting at part 1 and going clockwise. Red is given as R, green as G and blue as B.

1N1000001 \le N \le 100000, 1K1091 \le K \le 10^9

Output

Print one line holding the number of red parts, the number of green parts and the number of blue parts after all KK rounds, in that order, separated by single spaces.