1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 #include<map> 8 using namespace std; 9 #define MOD 1000000007 10 const int INF=0x3f3f3f3f; 11 const double eps=1e-5; 12 typedef long long ll; 13 #define cl(a) memset(a,0,sizeof(a)) 14 #define ts printf("***** "); 15 const int MAXN=2500; 16 char s[50][50]; 17 int n,m,tt; 18 pair<int,int> p1[MAXN],p2[MAXN],ans1,ans2; 19 int dis(int i,int j) 20 { 21 return (abs(p1[i].first-p2[j].first)+abs(p1[i].second-p2[j].second)); 22 } 23 int main() 24 { 25 int i,j,k; 26 #ifndef ONLINE_JUDGE 27 freopen("1.in","r",stdin); 28 #endif 29 while(scanf("%d%d",&n,&m)!=EOF) 30 { 31 if(n==0&&m==0) break; 32 int tot1=0,tot2=0; 33 for(i=0;i<n;i++) 34 { 35 scanf("%s",s[i]); 36 for(j=0;j<m;j++) 37 { 38 if(s[i][j]=='H') p1[tot1++]=make_pair(i,j); 39 if(s[i][j]=='C') p2[tot2++]=make_pair(i,j); 40 } 41 } 42 int Min=999999; 43 for(i=0;i<tot1;i++) 44 { 45 for(j=0;j<tot2;j++) 46 { 47 if(dis(i,j)<Min) 48 { 49 Min=dis(i,j); 50 ans1=p1[i]; 51 ans2=p2[j]; 52 } 53 } 54 } 55 printf("%d %d %d %d ",ans1.first,ans1.second,ans2.first,ans2.second); 56 } 57 }