Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  vector<vector<char>> d(m, vector<char>(n));
  int cnt = 0;
  for(int i=0;i<m;++i) {
    for(int j=0;j<n;++j) {
      cin >> d[i][j];
      if(d[i][j] == 'W') cnt++;
    }
  }

  int mi = cnt, mipos = 0;
  for(int i=0;i<n;++i) {
    for(int j=0;j<m;++j) {
      if(d[j][i] == 'W') cnt--;
      else cnt++;
    }
    if(cnt < mi) {
      mi = cnt;
      mipos = i+1;
    }
  }

  cout << mipos << " " << mipos+1 << endl;
}