
uses crt;
var
file1,file2:text;
m,n,i,j,k,l,o,z,o1,o2,s:integer;
a:array[1..50,1..50] of byte;
begin
clrscr;
assign(file1,'input.txt');
reset(file1);
read(file1,n,m);
for i:=1 to n do
for J:=1 to m do
read(file1,a[i,j]);
close(file1);
for i:=1 to n do
begin
writeln;
for J:=1 to m do write(a[i,j],' ');
end;

for i:=1 to n do
for j:=1 to m do
begin
k:=j;
while (a[i,k]<>1)and(k<=m) do k:=k+1;
if (k-j)>1 then begin
for l:=i to k do
begin
o2:=0;o1:=0;
while (a[j+o2,l]<>1)and(j+o2<=n) do o2:=o2+1;
while (a[j-o1,l]<>1)and(j-o1>=0) do o1:=o1+1;
s:=k+o2-o1;
end;
end;
end;
writeln('  ',s,'   ',k);
readkey
end.
