Colored marbles sit in a circle. Each marble is red, white, or green. Every second all marbles change color at the same time, and a marble's new color depends only on its own color and the color of the marble to its right.
The rules for changing color are:
You are given a string S and an integer N. Read S as an array of characters of length L, so the circle holds L marbles. The character W is a white marble, R is red, and G is green. Marble i+1 is to the right of marble i, and marble 0 is to the right of marble L−1. Determine the state of the circle after N seconds.
The first line contains T (T≤20), the number of test cases.
Each of the next T lines contains a string S (1≤∣S∣≤20000) and an integer N (1≤N≤1018) separated by a single space. S consists only of the characters W, R, and G.
For each test case, print one line in the form Case #X: W R G, where X is the test case number starting from 1, W is the number of white marbles, R is the number of red marbles, and G is the number of green marbles after N seconds. Separate the four values with a single space.