Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m;
  cin >> n >> m;

  vector<int> w(n, 0), e(n, 0);
  int allw = 0, alle = 0;
  for ( int i = 0; i < m; i++ ) {
    string d;
    cin >> d;    
    for ( int j = 0; j < n; j++ ) {
      if ( d[j] == 'W' ) {
	w[j]++;
	allw++;
      }
      else {
	e[j]++;
	alle++;
      }
    }    
  }

  int l = 0;
  int mi = allw;
  int sumw = allw, sume = 0;  
  for ( int i = 0; i < n; i++ ) {
    sumw -= w[i];
    sume += e[i];
    if ( mi > sumw+sume ) {
      l = i+1;
      mi = sumw+sume;      
    }
  }

  cout << l << " " << l+1 << endl;
  
  return 0;
}