We have created an infinite eight-directional crossword by taking a letter-filled block of dimensions and infinitely repeating it. For instance, if we are given the following block:
honi
hsin
then we create the following crossword:
...honihonihonihoni...
...hsinhsinhsinhsin...
...honihonihonihoni...
...hsinhsinhsinhsin...
that is infinite in all directions.
In the created crossword, we randomly choose a field and one of eight directions, then write down a word of length obtained by reading the crossword starting from the initial field, in the chosen direction. If we executed this query twice (independently), we would obtain two words of length . Calculate the probability that the two words are equal.
Input Specification
The first line of input contains integers , , from the task .
Each of the following lines contains lowercase letters of the English alphabet, and describes a block of the crossword. At least two distinct letters will exist in the block.
Output Specification
You must output the required probability in the form of a reduced fraction , without spaces.
Scoring
In test cases worth total points, it will hold .
Sample Input 1
1 2 2
ab
Sample Output 1
5/16
Sample Input 2
2 4 3
honi
hsin
Sample Output 2
19/512
Sample Input 3
3 3 10
ban
ana
nab
Sample Output 3
2/27
Comments