Square palindrome#2767

Square palindrome

2 secondi
256 megabyte
Media

Andrew has just made a breakthrough in computer science: he realized how to quickly find the largest palindrome square in a given rectangle of letters. Can you do the same?

A square consisting of rows of letters each is called an -sized palindrome square if each row and each column is a palindrome. A string is a palindrome if its first letter is the same as its last letter, its second letter is the same as its next-to-last letter, and so on.

Input

The first line contains two integers and (1 \leq h, w \leq 700) — the height and width of the rectangle. The next lines each contain lowercase English letters — the rectangle itself.

Output

Output four integers: the first row, first column, last row, and last column of the largest palindrome square within the rectangle. Rows are numbered from to , columns from to . If there are multiple solutions, output any of them.

Esempi

Esempio 1

Loading
Loading