54_B. Cutting Jigsaw Puzzle
The Hedgehog recently remembered one of his favorite childhood activities, — solving puzzles, and got into it with new vigor. He would sit day in, day out with his friend buried into thousands of tiny pieces of the picture, looking for the required items one by one.

Soon the Hedgehog came up with a brilliant idea: instead of buying ready-made puzzles, one can take his own large piece of paper with some picture and cut it into many small rectangular pieces, then mix them and solve the resulting puzzle, trying to piece together the picture. The resulting task is even more challenging than the classic puzzle: now all the fragments have the same rectangular shape, and one can assemble the puzzle only relying on the picture drawn on the pieces.

All puzzle pieces turn out to be of the same size X × Y, because the picture is cut first by horizontal cuts with the pitch of X, then with vertical cuts with the pitch of Y. If we denote the initial size of the picture as A × B, then A must be divisible by X and B must be divisible by Y (X and Y are integer numbers). 

However, not every such cutting of the picture will result in a good puzzle. The Hedgehog finds a puzzle good if no two pieces in it are the same (It is allowed to rotate the pieces when comparing them, but it is forbidden to turn them over). 

Your task is to count for a given picture the number of good puzzles that you can make from it, and also to find the puzzle with the minimal piece size.

Input

The first line contains two numbers A and B which are the sizes of the picture. They are positive integers not exceeding 20.

Then follow A lines containing B symbols each, describing the actual picture. The lines only contain uppercase English letters.

Output

In the first line print the number of possible good puzzles (in other words, the number of pairs (X, Y) such that the puzzle with the corresponding element sizes will be good). This number should always be positive, because the whole picture is a good puzzle itself. 

In the second line print two numbers — the sizes X and Y of the smallest possible element among all good puzzles. The comparison is made firstly by the area XY of one element and secondly — by the length X.

Examples

Input

2 4
ABDC
ABDC


Output

3
2 1


Input

2 6
ABCCBA
ABCCBA


Output

1
2 6

Note

The picture in the first sample test has the following good puzzles: (2, 1), (2, 2), (2, 4).
```python
def rotate(puzzle):
    n_puzzle = []
    for y in range(len(puzzle) - 1, -1, -1):
        n_puzzle.append(puzzle[y])
    result = []
    for x in range(len(puzzle[0])):
        col = []
        for y in range(len(puzzle)):
            col.append(n_puzzle[y][x])
        result.append(col)
    return result


def puzzle_match(p1, p2):
    r1 = p2
    r2 = rotate(p2)
    r3 = rotate(r2)
    r4 = rotate(r3)
    variants = [r1, r2, r3, r4]
    return p1 in variants


def make_puzzles(puzzle, x_cuts, y_cuts, a, b):
    x_size = a // x_cuts
    y_size = b // y_cuts
    result = []
    for x in range(x_cuts):
        for y in range(y_cuts):
            p = []
            for i in range(x_size):
                row = []
                for j in range(y_size):
                    row.append(puzzle[x * x_size + i][y * y_size + j])
                p.append(row)
            result.append(p)
    return result


class CodeforcesTask54BSolution:
    def __init__(self):
        self.result = ''
        self.a_b = []
        self.puzzle = []

    def read_input(self):
        self.a_b = [int(x) for x in input().split(" ")]
        for x in range(self.a_b[0]):
            self.puzzle.append(list(input()))

    def process_task(self):
        x_cuts = [x for x in range(1, self.a_b[0] + 1) if not self.a_b[0] % x][::-1]
        y_cuts = [x for x in range(1, self.a_b[1] + 1) if not self.a_b[1] % x][::-1]
        variants = 0
        varianted = []
        for x in x_cuts:
            for y in y_cuts:
                puzzles = make_puzzles(self.puzzle, x, y, self.a_b[0], self.a_b[1])
                rotated = []
                valid = True
                for p in puzzles:
                    r1 = p
                    r2 = rotate(r1)
                    r3 = rotate(r2)
                    r4 = rotate(r3)
                    for r in (r1, r2, r3, r4):
                        if r in rotated:
                            valid = False
                            break
                    if not valid:
                        break
                    rotated += [r1, r2, r3, r4]
                if valid:
                    variants += 1
                    varianted.append((self.a_b[0] // x, self.a_b[1] // y))
        varianted.sort(key=lambda x: x[0]*x[1])
        self.result = "{0}\n{1} {2}".format(variants, varianted[0][0], varianted[0][1])

    def get_result(self):
        return self.result


if __name__ == "__main__":
    Solution = CodeforcesTask54BSolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())

```