#include using namespace std; int h,w,x,y,t=2e6; vector s(2000); bool dfs(int x,int y) { if(s[x][y]=='#')return 1; if(--t==0) cout << "loop"; else if(dfs((x+1)%h,(y+1)%w))cout << x+1 << " " << y+1; return 0; } int main() { cin >> h >> w; for(int i = 0; i < h; i++) { cin >> s[i]; for(int j = 0; j < w; j++) if(s[i][j] == 'R') x=i,y=j; } if(dfs((x+1)%h,(y+1)%w)) cout << x+1 << " " << y+1; }