Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int d[10010][110];
int sum[10010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    string s;
    rep(i, 0, m){
        cin >> s;
        rep(j, 0, n){
            d[j][i] = (s[j] == 'W' ? 1 : 0);
        }
    }
    sum[0] = 0;
    rep(i, 0, n){
        rep(j, 0, m){
            sum[i + 1] += d[i][j];
        }
    }
    rep(i, 0, n){
        sum[i + 1] += sum[i];
    }
    int ans = -1, MIN = INF;
    rep(i, 0, n + 1){
        int left = m * i - sum[i];
        int right = sum[n] - sum[i];
        int tmp = left + right;
        // cout << i << ' ' << left << ' ' << right << endl;
        if(tmp < MIN){
            MIN = tmp; ans = i;
        }
    }
    cout << ans << " " << ans + 1 << endl;
}