#import int h,w,j,k;main(int,char*s){for(scanf("%d%d %[^a]",&h,&w,s);!j||!printf("loop\0%d %d"+s[k=k%h*w+j%--w]%52%6,k=k/w+1,j=k%++w);j+=s[k++]>81);}