You have a rectangular board of square cells with H rows and W columns. The rows are numbered 1 through H from top to bottom, and the columns are numbered 1 through W from left to right. The cell in row i and column j is written (i,j). Every cell is colored black or white.
You paint the board with the following operation.
One operation paints i×j cells. A cell counts as painted even when the operation leaves its color unchanged.
For example, take a 3×4 board and the choice of the cell (2,3) with the color black. The operation paints the six cells (1,1), (1,2), (1,3), (2,1), (2,2), (2,3) black, so it paints 6 cells, counting the ones that were already black.
You repeat the operation until the board matches the desired coloring, and you stop at the first moment it matches. Given the initial coloring and the desired coloring, compute the expected value of the total number of cells painted over the whole sequence of operations.
The input holds several datasets. There are at most 100 of them.
The first line of a dataset holds two integers H and W (1≤H,W≤5), the numbers of rows and columns of the board. Then comes the initial coloring, and after it the desired coloring. One coloring is given in H lines of W characters each, where B is a black cell and W is a white cell. One blank line separates the two colorings, and one blank line follows each dataset.
The input ends with a line holding two zeros. Do not process that line as a dataset.
For each dataset, print the expected total number of painted cells on its own line as an irreducible fraction p/q: the numerator, a slash, then the denominator, with q≥1 and gcd(p,q)=1. Print the denominator even when it is 1, so an expected value of 120 is printed as 120/1. When the initial coloring already matches the desired coloring, no operation is performed and the answer is 0/1.
The expected value is always a finite rational number.