Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n, m;
char d[10005][105];
int cw[10005], ce[10005];

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	cin >> n >> m;
	rep(j, 0, m) rep(i, 0, n) cin >> d[i][j];

	rep(i, 0, n) rep(j, 0, m) {
		if (d[i][j] == 'W') cw[i]++;
		if (d[i][j] == 'E') ce[i]++;
	}

	rep(i, 1, n + 1) {
		cw[i] += cw[i - 1];
		ce[i] += ce[i - 1];
	}

	// [0, i), [i, n), i.e. between i and i + 1
	int minv = 0x3f3f3f3f, bans;
	rep(i, 0, n + 1) {
		int we = i ? ce[i - 1] : 0;
		int ew = cw[n - 1] - (i ? cw[i - 1] : 0);
		//cout << i << "," << i + 1 << ": " << we << ", " << ew << endl;
		if (we + ew < minv) {
			minv = we + ew;
			bans = i;
		}
	}
	cout << bans << " " << bans + 1 << endl;
}