Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    char c[m][n];
    rep(i, m)rep(j, n) scanf(" %c", &c[i][j]);
    int wsum[n+1], esum[n+1];
    wsum[n] = esum[0] = 0;
    rep(i, n){
        int w = 0;
        rep(j, m) w += (c[j][i] == 'W');
        wsum[i] = w;
        esum[i+1] = m-w;
    }
    rrep(i, n) wsum[i] += wsum[i+1];
    rep(i, n) esum[i+1] += esum[i];
    int tmp = mod, id = -1;
    rep(i, n+1)if(chmin(tmp, wsum[i] + esum[i])) id = i;
    printf("%d %d\n", id, id+1);
}