Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> w(n+1,0),e(n+1,0);
  char c;
  rep(j,m){
    rep(i,n){
      cin >> c;
      if(c=='W'){
        w[i]++;
      }else{
        e[i+1]++;
      }
    }
  }
  rep(i,n){
    e[i+1]+=e[i];
  }
  per(i,n){
    w[i]+=w[i+1];
  }
  int mi=IINF;
  int id=-1;
  rep(i,n+1){
    if(mi>e[i]+w[i]){
      mi=e[i]+w[i];
      id=i;
    }
  }
  cout << id SP id+1 << endl;
  return 0;
}