Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define long long long // for codeforces

int main(){
  int n,m;
  cin>>n>>m;
  vector<string> vec(m);
  rep(i,m) cin>>vec[i];

  int e = 0;
  int w = 0;
  rep(i,m)rep(j,n) if(vec[i][j]=='W') w++;

  int best = 0;
  int bestd = w+e;
  rep(i,n){
    rep(j,m){
      if(vec[j][i]=='E') e++;
      else w--;
    }
    int nd = w+e;
    if(nd < bestd){
      bestd = nd;
      best = i+1;
    }
  }

  cout << best << " " << best+1 << endl;

  return 0;
}