Circles

Time limit: 1.3s Memory limit: 512MB Input: Output:

Two of the most mischievous Dacians in history, Danillo and Stegano, thought it would be funny to dig some tunnels that go nowhere. They knew that future historians would be extremely confused about the existence of some random tunnels and would try to speculate their purpose, but the tunnels would be, in fact, useless.

They found a huge wall in which they could start digging, but unfortunately, some patches of the wall would be unbreakable, so they would have to avoid them. The entrance to the tunnel would have to be circular for aesthetic reasons.

Formally, the wall can be described as a cartesian plane with xx coordinates in the range [0,M][0,M] and yy coordinates in the range [0,N][0,N]. The patches that are unbreakable are squares with sides parallel to the axes of length 11 with corners in integer coordinates. The map of the zones that can be broken can be described by a binary matrix with NN lines numbered from 00 to N1N−1 and MM columns numbered from 00 to M1M−1. If the element from line ll and column cc is 11, then all the points (x,y)(x,y) with cxc+1c≤x≤c+1 and lyl+1l≤y≤l+1 can be mined. Note the difference between the coordinates (x,y)(x, y) in the plane and the coordinates (l,c)(l, c) of elements in the matrix.

When mining a tunnel, the two select a point with integer coordinates (x,y)(x,y) as the center of the tunnel, then they select a radius rr, and, finally, they start digging through all the points that lie inside the disc with the center in (x,y)(x,y) of radius rr. Note that the disc includes all the points inside, not just on the boundary of the circle, and the disc must lie completely inside the defined plane.

Task

They want the tunnel to be as noticeable as possible, so they want the tunnel with the largest radius. For easier construction, if there are multiple such tunnels, they want the one that is the easiest to dig. If the center of the tunnel is in coordinates (x,y)(x,y), they want the one with the smallest yy. If there are still multiple tunnels to choose from, they want the one with the smallest xx.

Input data

The first line contains two integers NN and MM in this order, defining the plane and the lengths of the binary matrix.

The following NN lines each contain a string of length MM consisting of 00's and 11's, denoting the elements of the matrix defined above.

Output data

On a single line, you must print three space separated integers xx, yy and RR. (x,y)(x, y) represent the coordinates of the center of the tunnel that Danillo and Stegano will dig, and RR represents the radius of the circle, squared and rounded to the nearest integer. If there are no circles with positive integers, you must print 0 0 0.

Constraints and clarifications

  • 1N,M3 0001 \leq N, M \leq 3 \ 000
# Points Constraints
0 0 Examples
1 4 The matrix contains exactly four cells with 11.
2 9 The 11's in the matrix form a rectangle with sides parallel to the axes.
3 14 N,M50N, M \leq 50
4 15 N,M600N, M \leq 600
5 21 The matrix is randomly generated.
6 37 No additional constraints

Example 1

stdin

5 6
011110
111110
011111
111111
011110

stdout

3 2 4

Explanation

Example 2

stdin

3 3
010
101
010

stdout

0 0 0

Log in or sign up to be able to send submissions!