Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

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

int INF = (1 << 30);

int N, M;
string str[10101];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> str[i];
	}

	int C[10101];

	for (int i = 0; i < N; ++i) {
		int count = 0;
		for (int j = 0; j < M; ++j) {
			count += str[j][i] == 'W' ? 1 : 0;
		}
		C[i] = count;
	}


	int dif = 0; for (int i = 0; i < N; ++i) { dif += C[i]; }

	int ret = 0;
	int min_dif = dif;

	for (int i = 0; i < N; ++i) {
		dif += M - 2 * C[i];
		if (dif < min_dif) {
			min_dif = dif;
			ret = i + 1;
		}
	}
	cout << ret << ' ' << ret + 1 << endl;
	return 0;
}