Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int W[n+1],E[n+1];
    fill(W,W+n+1,0);
    fill(E,E+n+1,0);
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            char c;
            cin>>c;
            W[j+1]+=(c=='W');
            E[j+1]+=(c=='E');
        }
    }
    for(int i=1;i<=n;i++){
        W[i]+=W[i-1];
        E[i]+=E[i-1];
    }
    int ans=-1,cost=100000000;
    for(int i=0;i<=n;i++){
        //i,i+1????¢????
        int err = E[i]+W[n]-W[i];
        if(err<cost){
            ans=i; cost=err;
        }
    }
    cout<<ans<<' '<<ans+1<<endl;

    return 0;
}