var
n,m,i,j,shu:longint;
f:array[-7..107,-7..107]of longint;
z:array[1..100,1..100]of char;
s:ansistring;
begin
assign(input,'kadun.in');
assign(output,'kadun.out');
reset(input);
rewrite(output);
readln(n,m);
shu:=n*m;
for m:=1 to m do
begin
readln(s);
for n:=1 to n do
begin
if s[n]='X' then dec(shu);
if s[n]='N' then
for i:=m-3 to m+3 do
for j:=n-3 to n+3 do
if (i<>m)or(j<>n) then
inc(f[i,j]);
if s[n]='C' then
for i:=m-2 to m+2 do
for j:=n-2 to n+2 do
if (i<>m)or(j<>n) then
inc(f[i,j]);
if s[n]='Z' then
for i:=m-1 to m+1 do
for j:=n-1 to n+1 do
if (i<>m)or(j<>n) then
inc(f[i,j]);
end;
end;
for m:=1 to m do
for n:=1 to n do
if f[m,n]=shu then
begin
writeln(n,' ',m);
exit;
end;
close(input);close(output);
end.