uses math;
const irany:array[1..2,1..4] of integer=((-1,1,0,0),(0,0,-1,1));
var i,j,n,m,l,k,maxim,x,y:integer;
rom,jul:array[0..102,0..102] of integer;
f,g:text;
t,ok:boolean;
c:char;
procedure dolgozzromeo(i,j:integer);
begin
for l:=1 to 4 do
if rom[i+irany[1,l],j+irany[2,l]]=0
then begin rom[i+irany[1,l],j+irany[2,l]]:=k+1; ok:=false; if jul[i+irany[1,l],j+irany[2,l]]>0 then t:=true; end;
if (rom[i+1,j+1]=0) or (rom[i+1,j+1]>k+1) then if (rom[i+1,j]=0) and (rom[i,j+1]=0) then begin rom[i+1,j+1]:=k+1; ok:=false;
if jul[i+1,j+1]>0 then t:=true; end;
if (rom[i-1,j-1]=0) or (rom[i-1,j-1]>k+1) then if (rom[i-1,j]=0) and (rom[i,j-1]=0) then begin rom[i-1,j-1]:=k+1; ok:=false;
if jul[i-1,j-1]>0 then t:=true; end;
if (rom[i+1,j-1]=0) or (rom[i+1,j-1]>k+1) then if (rom[i+1,j]=0) and (rom[i,j-1]=0) then begin rom[i+1,j-1]:=k+1; ok:=false;
if jul[i+1,j-1]>0 then t:=true; end;
if (rom[i-1,j+1]=0) or (rom[i-1,j+1]>k+1) then if (rom[i-1,j]=0) and (rom[i,j+1]=0) then begin rom[i-1,j+1]:=k+1; ok:=false;
if jul[i-1,j+1]>0 then t:=true; end;
end;
procedure dolgozzjulia(i,j:integer);
begin
for l:=1 to 4 do
if jul[i+irany[1,l],j+irany[2,l]]=0
then begin jul[i+irany[1,l],j+irany[2,l]]:=k+1; ok:=false; if rom[i+irany[1,l],j+irany[2,l]]>0 then t:=true end;
if (jul[i+1,j+1]=0) or (jul[i+1,j+1]>k+1) then if (jul[i+1,j]=0) and (jul[i,j+1]=0) then begin jul[i+1,j+1]:=k+1; ok:=false;
if rom[i+1,j+1]>0 then t:=true end;
if (jul[i-1,j-1]=0) or (jul[i-1,j-1]>k+1) then if (jul[i-1,j]=0) and (jul[i,j-1]=0) then begin jul[i-1,j-1]:=k+1; ok:=false;
if rom[i-1,j-1]>0 then t:=true end;
if (jul[i+1,j-1]=0) or (jul[i+1,j-1]>k+1) then if (jul[i+1,j]=0) and (jul[i,j-1]=0) then begin jul[i+1,j-1]:=k+1; ok:=false;
if rom[i+1,j-1]>0 then t:=true end;
if (jul[i-1,j+1]=0) or (jul[i-1,j+1]>k+1) then if (jul[i-1,j]=0) and (jul[i,j+1]=0) then begin jul[i-1,j+1]:=k+1; ok:=false;
if rom[i-1,j+1]>0 then t:=true end;
end;
begin
assign(f,'rj.in'); reset(f);
assign(g,'rj.out'); rewrite(g);
readln(f,n,m);
for i:=0 to n+1 do
begin
rom[i,0]:=-1;
rom[i,m+1]:=-1;
jul[i,0]:=-1;
jul[i,m+1]:=-1;
end;
for i:=0 to m+1 do
begin
rom[0,i]:=-1;
rom[n+1,i]:=-1;
jul[0,i]:=-1;
jul[n+1,i]:=-1;
end;
for i:=1 to n do
begin
for j:=1 to m+2 do
begin
read(f,c);
if pos(c,'XRJ xrj')>0 then
if c='X' then begin rom[i,j]:=-1; jul[i,j]:=-1; end
else
if c='R' then
begin
rom[i,j]:=1;
end
else
if c='J' then
begin
jul[i,j]:=1;
end
else begin rom[i,j]:=0; jul[i,j]:=0; end;
end;
end;
t:=false;
k:=1;
repeat
for i:=1 to n do
for j:=1 to m do
begin
if rom[i,j]=k then dolgozzromeo(i,j);
if jul[i,j]=k then dolgozzjulia(i,j)
end;
inc(k);
until t;
maxim:=0;
for i:=1 to n do
for j:=1 to m do if max(rom[i,j],jul[i,j])>maxim then begin
maxim:=max(rom[i,j],jul[i,j]);
x:=i;
y:=j;
end;
writeln(g,maxim-1,' ',x,' ',y);
close(g);
end.