Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int>P;

int sum[10001];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m) {
		string s; cin >> s;
		rep(j, n) {
			if (s[j] == 'W')sum[j + 1]++;
		}
	}
	for (int i = 1; i <= n; i++)sum[i] += sum[i - 1];
	int id, Min = INT_MAX;
	for (int i = 0; i <= n; i++) {
		int a = i*m - sum[i], b = sum[n] - sum[i];
		if (Min > a + b) {
			Min = a + b; id = i;
		}
	}
	printf("%d %d\n", id, id + 1);
}