Classroom Attention

No attempts yetTime limit1sMemory limit1024 MB

Problem

The class is full of students seated in a grid of rows and columns. Each student is interested, to some degree, in computers and in sports. A student interested only in sports is marked $0$; a student interested only in computers is marked $9$; every other student is marked with a digit from $1$ to $8$ according to how strong their interest is.

Students with similar interests chatter among themselves and ignore the teacher. The smaller the difference in interest between two adjacent students, the more they chatter.

A student's attention is defined as the average of the absolute differences between that student's interest and the interests of their neighbours. A neighbour is a student seated directly in front of, behind, to the left of, or to the right of the given student. The class's total attention is the sum of the attention values of all students.

The teacher wants to raise the class's attention by swapping the seats of exactly two students. Determine the maximum amount by which the class's total attention can be increased with a single swap.

Input

The first line contains two integers $M$ and $N$ ($1 \le M \le 200$, $1 \le N \le 200$), the number of rows and columns in the class. Each of the next $M$ lines contains exactly $N$ characters, each a digit from $0$ to $9$, giving the students' interest levels.

Output

Output the maximum increase in the class's total attention obtainable by swapping the seats of exactly two students, as a fraction in lowest terms. Print it as p/q with $\gcd(p, q) = 1$ and $q \ge 1$; if the reduced denominator equals $1$, print only the integer $p$. If no swap can increase the class's total attention, print $0$.

Hint

Worked example (on the grid above): the attention of the student in row 2, column 4 (interest $7$) is $(|7-1| + |7-3| + |7-8|)/3 = (6+4+1)/3 = 11/3$. The class's total attention is $93/2$.

The best move is to swap the student in row 1, column 3 with the student in row 3, column 4; this raises the class's total attention by $34/3$.