#include <bits/stdc++.h>
using namespace std;
ifstream fin("rj.in");
ofstream fout("rj.out");
int noLines, noColumns;
char mt[101][101];
void moveRj(pair<int, int> currentPos[10001], int ¤tPosLen, map<pair<int, int>, bool> &frPos) {
int nextPosLen = 0;
pair<int, int> nextPos[10001];
for (int i = 1; i <= currentPosLen; ++i) {
int l = currentPos[i].first, c = currentPos[i].second;
if (l > 1 && strchr(" RJ", mt[l - 1][c]) != 0 && frPos.count({l - 1, c}) == 0) {
nextPos[++nextPosLen] = {l - 1, c};
frPos[{l - 1, c}] = 1;
}
if (l > 1 && c < noColumns && strchr(" RJ", mt[l - 1][c + 1]) != 0 && frPos.count({l - 1, c + 1}) == 0) {
nextPos[++nextPosLen] = {l - 1, c + 1};
frPos[{l - 1, c + 1}] = 1;
}
if (c < noColumns && strchr(" RJ", mt[l][c + 1]) != 0 && frPos.count({l, c + 1}) == 0) {
nextPos[++nextPosLen] = {l, c + 1};
frPos[{l, c + 1}] = 1;
}
if (l < noLines && c < noColumns && strchr(" RJ", mt[l + 1][c + 1]) != 0 && frPos.count({l + 1, c + 1}) == 0) {
nextPos[++nextPosLen] = {l + 1, c + 1};
frPos[{l + 1, c + 1}] = 1;
}
if (l < noLines && strchr(" RJ", mt[l + 1][c]) != 0 && frPos.count({l + 1, c}) == 0) {
nextPos[++nextPosLen] = {l + 1, c};
frPos[{l + 1, c}] = 1;
}
if (l < noLines && c > 1 && strchr(" RJ", mt[l + 1][c - 1]) != 0 && frPos.count({l + 1, c - 1}) == 0) {
nextPos[++nextPosLen] = {l + 1, c - 1};
frPos[{l + 1, c - 1}] = 1;
}
if (c > 1 && strchr(" RJ", mt[l][c - 1]) != 0 && frPos.count({l, c - 1}) == 0) {
nextPos[++nextPosLen] = {l, c - 1};
frPos[{l, c - 1}] = 1;
}
if (l > 1 && c > 1 && strchr(" RJ", mt[l - 1][c - 1]) != 0 && frPos.count({l - 1, c - 1}) == 0) {
nextPos[++nextPosLen] = {l - 1, c - 1};
frPos[{l - 1, c - 1}] = 1;
}
}
for (int i = 1; i <= nextPosLen; ++i) {
currentPos[i] = nextPos[i];
// cout << currentPos[i].first << ' ' << currentPos[i].second << '\n';
}
// cout << '\n';
currentPosLen = nextPosLen;
}
int main() {
int currentPosRlen = 0, currentPosJlen = 0;
pair<int, int> currentPosR[10001];
pair<int, int> currentPosJ[10001];
fin >> noLines >> noColumns;
fin.get();
for (int i = 1; i <= noLines; ++i) {
fin.getline(mt[i] + 1, 101);
for (int j = 1; j <= noColumns; ++j) {
if (mt[i][j] == 'R') {
currentPosR[++currentPosRlen] = {i, j};
} else if (mt[i][j] == 'J') {
currentPosJ[++currentPosJlen] = {i, j};
}
}
}
bool ansFound = 0;
map<pair<int, int>, bool> frPosR;
map<pair<int, int>, bool> frPosJ;
frPosR[currentPosR[1]] = 1;
frPosJ[currentPosJ[1]] = 1;
int time = 1, minTime = 10001;
pair<int, int> meetingPoint = {10001, 10001};
while (ansFound == 0) {
moveRj(currentPosR, currentPosRlen, frPosR);
moveRj(currentPosJ, currentPosJlen, frPosJ);
++time;
// cout << time << ' ';
for (int i = 1; i <= currentPosRlen; ++i) {
for (int j = 1; j <= currentPosJlen; ++j) {
if (currentPosR[i] == currentPosJ[j]) {
ansFound = 1;
minTime = time;
meetingPoint = min(meetingPoint, currentPosR[i]);
}
}
}
}
fout << minTime << ' ' << meetingPoint.first << ' ' << meetingPoint.second;
return 0;
}
/*
*/