{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R-,S-,T-,V+,X+}
{$M 16384,0,655360}
program gaju;
type tip=record
xx,yy:integer;
end;
const oriz:array[1..8]of shortint=(-1,-1,-1,0,0,1,1,1);
vert:array[1..8]of shortint=(-1,0,1,1,-1,-1,0,1);
var f,g:text;
n,m,i,j,a,xnou,ynou,pas,x,y,xx,yy,c,d,k,h:integer;
modif,fost:boolean;
s:string[100];
tata:array[1..100,1..100]of tip;
v:array[1..100,1..100]of integer;
procedure tati(xnou,ynou:integer;var c,d:integer);
begin
while (xnou<>0 )or (ynou<>0) do begin
c:=xnou;
d:=ynou;
xnou:=tata[xnou,ynou].xx;
ynou:=tata[xnou,ynou].yy;
end;
end;
begin
assign(f,'rj.in');
assign(g,'rj.out');
reset(f);
rewrite(g);
readln(f,n,m);
for i:=1 to n do begin
readln(f,s);
for j:=1 to m do
if (s[j]=' ')or(s='')or(s[j]=#0) then v[i,j]:=n*m+1
else
if s[j]='X' then v[i,j]:=0
else
if s[j]='R' then v[i,j]:=1
else
if s[j]='J' then v[i,j]:=1;
s:='';
end;
pas:=1;
modif:=true;
while modif do begin
modif:=false;
for i:=1 to n do
for j:=1 to m do
if v[i,j]=pas then
for a:=1 to 8 do begin
xnou:=i+oriz[a];
ynou:=j+vert[a];
if( xnou in [1..n])and(ynou in [1..m]) then begin
fost:=false;
if ((v[xnou,ynou]>pas+1)and(v[xnou,ynou]<>0))
then begin
v[xnou,ynou]:=pas+1;
tata[xnou,ynou].xx:=i;
tata[xnou,ynou].yy:=j;
modif:=true;
fost:=true;
end;
if (fost=false)and(v[xnou,ynou]=pas+1)then begin
tati(i,j,c,d);
tati(xnou,ynou,k,h);
if (c<>k )and (d<>h) then begin
i:=n;j:=m;
modif:=false;
x:=xnou;y:=ynou;
end;
end;
end;
end;
pas:=pas+1;
end;
writeln(g,pas,' ',x,' ',y);
close(g);close(f);
end.