Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

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

string s[105];
int cnt[10010][2];
int main() {
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; ++i) cin >> s[i];
	
	int numw = 0, nume = 0;
	for(int i=0; i<n; ++i) {
		for(int j=0; j<m; ++j) {
			if(s[j][i] == 'W') cnt[i][0]++, numw++;
			else cnt[i][1]++, nume++;
		}
	}
		
	int w = 0, e = 0;
	int ret = numw-w, idx = -1;
	for(int i=0; i<n; ++i) {
		w += cnt[i][0];
		e += cnt[i][1];
		// ????????\??£????????£??????e?????°?????? e
		// ????????\??£????????£??????w?????° ??? numw - w
		if( ret > e + numw - w) {
			ret = e + numw - w;
			idx = i;
		}		
	}
	cout << idx+1 << " " << idx+2 << endl;
}