Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define MAX 20010
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n,m;
  int c[MAX]={};

  cin>>n>>m;
  FOR(i,0,m){
    string s;
    cin>>s;
    FOR(j,0,s.length())if(s[j]=='W')c[j]++;
  }

  int w=0,e=0;
  FOR(i,0,n)e+=c[i];
  pii ans(e,-1);
  FOR(i,0,n){
    w+=m-c[i];
    e-=c[i];
    if(w+e<ans.f)ans=mp(w+e,i);
  }
  cout<<ans.s+1<<" "<<ans.s+2<<endl;
  return 0;
}