Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
signed main(){
    int N,M;
    cin>>N>>M;
 
    vint sum(N);
    rep(i,M){
        string s;
        cin>>s;
        rep(j,N){
            if(s[j]=='W')sum[j]++;
        }
    }
 
    int allW=accumulate(all(sum),0ll);
 
    int mi=-1,mic=1001001001001001001ll;
    int cur=0;
    for(int i=0;i<=N;i++){
        int cost=0;
        cost+=M*i-cur;
        cost+=allW-cur;
        if(mic>cost){
            mi=i;
            mic=cost;
        }
        if(i<N)cur+=sum[i];
    }
 
    cout<<mi<<" "<<mi+1<<endl;
    return 0;
}