#0000FA

z-rubik's cube

In the World championship in solving Rubik's cube, little Z unfortunately went out in qualification round, so he is now competing for an consolation prize. In this contest, knowledge is not as important as the luck is. Each competitor receives a computer generated sequence of moves to make on Rubik's cube.


There are no moves that allow rotation of whole cube in the space - only one side of the cube is allowed to be rotated. There are six basic moves: L,R,U,D,F and B which represent 90 degree clockwise rotation. On the image below you can see the basic moves.


Image: notation

Also, another two groups of six moves each are allowed. One of them are double rotations: L2, R2, U2, D2, F2 and B2 which represent 180 degree rotations of the nominated side. Last group are backward moves: L', R' ,U' ,D' ,F' and B' which represent 90 degree counter-clockwise rotations. These two types of moves are given with two signs (the basic move + 2 or ').


The starting position is a solved Rubik's cube configuration i.e. all cube sides are of the same color. After that the judges check if the given commands are executed properly, and finally assigns points for the final pattern obtained.


For every of the six cube sides, the competitors can earn 0 to 5 points. One point for any of five possible symmetries (four axial and one central). On the "sample" image, front side earn 3 points (diagonals and central symmetries), right side 1 point (for central) and top side 1 point (for horizontal axis symmetry).


InputIn first line of standard input You have sequence of moves. 8 possible character will be in sequence: L, R, U, D, F, B, 2 i ' (single quote). The number of moves will be <= 1 500 000.

OutputTo the first line of standard output You need to write six integers separated with space characters. Numbers should represent points which little Z earned in this "Lucky looser contest". Output sequence need to be in format "f r b l u d" (front, right back, left, up, down).

Example 1
Input:
R'L
Output:
3 5 3 5 3 3
Explanation: After this two moves, Left and Right sides of the cube stay unchanged. That is 5 points for each. Up, Down, Front and Back sides are worth 3 points each, image "Example 1". (horizontal and vertical axis symmetry, and central as well).

Image: scoring

Example 2
Input:
R2L2U2D2F2B2
Output:
5 5 5 5 5 5
Explanation: After all six sides of the cube are rotated by 90 degrees, all the 6 sides have same pattern - with all five symmetries in presence, image "Example 2".

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.