Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int d1[4] = { -1,0,1,0 };
int d2[4] = { 0,1,0,-1 };
int main() {
	int n, m; cin >> n >> m;
	char jagan[10000][100];
	string s;
	rep(i, m) {
		cin >> s;
		rep(j, n) {
			jagan[j][i] = s[j];
		}
	}
	int wcnt[10000] = {};
	int sum = 0;
    int out = 0;
	rep(i, n) {
		rep(j, m) {
			if (jagan[i][j] == 'W') {
				wcnt[i]++; sum++;
			}
		}
	}
	int mi = sum;
	rep(i, n) {
		sum += m - 2*wcnt[i];
		if (sum < mi) {
			mi = sum; out = i + 1;
		}
	}
	cout << out << " " << out + 1 << endl;
	return 0;
}