Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> mp(n+1);
    mp[0]=make_pair(0,0);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            char c;
            cin>>c;
            if(c=='W')mp[j+1].first++;
            else mp[j+1].second++;
        }
    }
    for (int i = 1; i <= n; ++i) {
        mp[i].first+=mp[i-1].first;
        mp[i].second+=mp[i-1].second;
    }
    int ans=n*m+1;
    int ansind=-1;
    for (int i = 0; i <= n; ++i) {
        int l=mp[i].second-mp[0].second;
        int r=mp[n].first-mp[i].first;
        if(ans>l+r){
            ans=l+r;
            ansind=i;
        }
    }
    cout<<ansind<<" "<<ansind+1<<endl;
    return 0;
}