Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <iostream>
using namespace std;

constexpr int INF = 1 << 29;

int N, M;
string d[10101];

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

    int w[10101];

    for (int j = 0; j < N; ++j) {
        int count = 0;
        for (int k = 0; k < M; ++k) {
            count += d[k][j] == 'W' ? 1 : 0;
        }
        w[j] = count;
    }


    int errs = 0; for (int j = 0; j < N; ++j) { errs += w[j]; }

    int ret = 0;
    int min_errs = errs;

    for (int j = 0; j < N; ++j) {
        errs += M-2*w[j];
        if (errs < min_errs) {
            min_errs = errs;
            ret = j+1;
        }
    }
    cout << ret << ' ' << ret+1 << endl;
    return 0;
}