Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

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

int main()
{
	int n, m;
	cin >> n >> m;
	char c;
	vector<vector<int>> d(m, vector<int>(n + 2));
	for (int i = 0; i < m; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> c;
			if (c == 'E') {
				d[i][j] = 1;
			}
		}
		d[i][n + 1] = 1;
	}
	for (int i = 0; i < m; i++) {
		for (int j = 1; j <= n + 1; j++) {
			d[i][j] += d[i][j - 1];
		}
	}
	int res, merr = n * m;
	for (int i = 1; i <= n + 1; i++) {
		int err = 0;
		for (int j = 0; j < m; j++) {
			err += d[j][i - 1] + (n + 2 - i - (d[j][n + 1] - d[j][i - 1]));
		}
		if (err < merr) {
			merr = err;
			res = i - 1;
		}
	}
	cout << res << ' ' << res + 1 << endl;
	return 0;
}