There is a board of circles with n rows and m columns. Each circle is divided in four equal regions. Each of the four regions is colored with distinct colors. You can select a circle and rotate it 90 degrees clockwise. A state of the board is beautiful if the two adjacent regions of every pair of neighboring circles have the same color.
Given the initial state of the board, how many different beautiful states you can reach by performing the action as many times as you want. Two states are considered different if there is at least one circle that has different rotations in both states.
Image for second test case. In the left of the image is the state of the circles as described in the input. In the right are the two beautiful states. Note that colors are [r]ed, [b]lue, [p]urple, [y]ellow and [o]range.