Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <iostream>
using namespace std;

int N,M;
char D[110][10010];
int cnt[10010] = {};

int main(){
    cin >> N >> M;
    for(int i=1;i<=M;i++){
        for(int j=1;j<=N;j++){
            cin >> D[i][j];
            if(D[i][j]=='W') cnt[j]++;
        }
    }
    for(int i=1;i<=N;i++) cnt[i] += cnt[i-1];
    int l = 0,r = 1,mi = cnt[N];
    for(int i=1;i<=N;i++){
        int e1 = i*M-cnt[i],e2 = cnt[N]-cnt[i];
        if(e1+e2<mi){
            l = i; r = i+1; mi = e1+e2;
        }
    }
    cout << l << " " << r << endl;
}