Osmosmjerka

Given a letter block tiled infinitely in all directions, pick a random start square and one of 8 directions twice, and report the probability that the two read words of length K match, as a reduced fraction.

Hard8MathString matchingHash mapCombinatoricsNo attempts yetTime limit4sMemory limit256 MB

Problem

Repeating a block of letters with MM rows and NN columns in every direction gives an infinite eight-direction word search. For example, this block

honi
hsin

builds the crossword

...honihonihonihoni...
...hsinhsinhsinhsin...
...honihonihonihoni...
...hsinhsinhsinhsin...

which runs on forever left, right, up and down.

Pick one square of the crossword at random, and one of the eight directions at random. Start at that square, step one square at a time in that direction, and read KK letters. That gives a word of length KK. Since the crossword is one block repeated, every square of the crossword matches some square of the block, so picking the starting square is the same as drawing one of the M×NM \times N squares of the block uniformly. The direction is drawn uniformly from the eight as well.

Run this trial twice, independently. Compute the probability that the two words are equal.

Input

The first line contains the integers MM, NN, KK (1M,N5001 \le M, N \le 500, 2K1092 \le K \le 10^9).

Each of the next MM lines contains NN lowercase letters of the English alphabet and describes one row of the block. The block contains at least two different letters.

Output

Print the probability as a reduced fraction p/q, with no spaces.