Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

string s[101];
int w[101][10001],e[101][10001];
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        cin>>s[i];
        rep(j,n){
            if(s[i][j]=='W') ++w[i][j+1];
            else ++e[i][j+1];
        }
        rep(j,n){
            w[i][j+1]+=w[i][j];
            e[i][j+1]+=e[i][j];
        }
    }
    int l,r,mn=1000100010;
    rep(i,n+1){
        int sum=0;
        rep(j,m){
            sum+=e[j][i]-e[j][0];
            sum+=w[j][n]-w[j][i];
        }
        if(mn>sum) mn=sum,l=i,r=i+1;
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}