Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

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

int main(void) {
    
    int n, m; cin >> n >> m;

    char map[102][10002];
    int array[10002];

    int temp = 0;
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            char input; cin >> input;
            map[i][j] = input;
            if(input == 'W') temp++;
        }
    }
    array[0] = temp;
    int min = temp;
    int min_j = 0;
    for(int j = 0; j < n; j++){
        for(int i = 0; i < m; i++){
            if(map[i][j] == 'W') temp--;
            else temp++;
        }
        array[j+1] = temp;
        if(min > temp){
            min = temp;
            min_j = j + 1;
        }
    }

    cout << min_j << " " << min_j + 1 << endl;
    return 0;
}