Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,n;
  cin >> n >> m;
  string s[105];
  int i,j,k;
  for(i=0;i<m;i++){
    cin >> s[i];
  }
  int d[10005]={};
  
  for(i=0;i<n;i++){
    d[i+1]=d[i];
    for(j=0;j<m;j++){ 
      if(s[j][i]=='W') d[i+1]++;
    }
  }
  
  int mi=1000005;
  int l=0;
  for(i=0;i<=n;i++){
    if(i*m+d[n]-2*d[i]<mi){
      l=i;
      mi=i*m+d[n]-2*d[i];
    }
  }
  
  cout << l << " " << l+1 << endl;
  return 0;
}