Problem: There is an area map that is a rectangular matrix n × m, each cell of the matrix contains the average height of a corresponding area part. Peter works for a company that has to build several cities within this area, each of the cities will occupy a rectangle a × b cells on the map. To start construction works in a particular place Peter needs to remove excess ground from the construction site where a new city will be built. To do so he chooses a cell of the minimum height within this site, and removes excess ground from other cells of the site down to this minimum level. Let's consider that to lower the ground level from h2 to h1 (h1 ≤ h2) they need to remove h2 - h1 ground units.

Let's call a site's position optimal, if the amount of the ground removed from this site is minimal compared to other possible positions. Peter constructs cities according to the following algorithm: from all the optimum site's positions he chooses the uppermost one. If this position is not unique, he chooses the leftmost one. Then he builds a city on this site. Peter repeats this process untill he can build at least one more city. For sure, he cannot carry out construction works on the occupied cells. Would you, please, help Peter place cities according to the algorithm? 

Input

The first line contains four space-separated integers: map sizes n, m and city sizes a, b (1 ≤ a ≤ n ≤ 1000, 1 ≤ b ≤ m ≤ 1000). Then there follow n lines, each contains m non-negative space-separated numbers, describing the height matrix. Each number doesn't exceed 109. 

Output

In the first line output k — the amount of constructed cities. In each of the following k lines output 3 space-separated numbers — the row number and the column number of the upper-left corner of a subsequent construction site, and the amount of the ground to remove from it. Output the sites in the order of their building up.

Examples

Input

2 2 1 2
1 2
3 5


Output

2
1 1 1
2 1 2


Input

4 4 2 2
1 5 3 4
2 7 6 1
1 1 2 2
2 2 1 2


Output

3
3 1 2
3 3 3
1 2 9

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9) + 7;
const long double EPS = 1E-9;
const long double PI = acos(-1.0);
const int N = 1010;
int n, m;
int a, b;
int f[N][N];
long long sum[N][N];
inline long long getSum(int lfx, int lfy, int rgx, int rgy) {
  long long res = sum[rgx][rgy];
  if (lfx > 0) res -= sum[lfx - 1][rgy];
  if (lfy > 0) res -= sum[rgx][lfy - 1];
  if (lfx > 0 && lfy > 0) res += sum[lfx - 1][lfy - 1];
  return res;
}
int m1[N][N], m2[N][N];
int H, T;
pair<int, int> q[2 * N];
inline void add(int v, int i) {
  pair<int, int> cur(v, i);
  while (H != T && q[T - 1].first > v) {
    T--;
  }
  q[T++] = cur;
}
inline void pop(int i) {
  if (H != T && q[H].second == i) H++;
}
inline int getMin() {
  if (H == T) throw;
  return q[H].first;
}
struct pl {
  long long d;
  int sx, sy;
  pl() {}
  pl(const long long& d, int sx, int sy) : d(d), sx(sx), sy(sy) {}
  bool operator<(const pl& c) const {
    if (d != c.d) return d < c.d;
    if (sx != c.sx) return sx < c.sx;
    return sy < c.sy;
  }
};
int szt;
pl t[N * N];
int ans;
bool ina[N * N];
bool used[N][N];
int main() {
  cin >> n >> m >> a >> b;
  for (int i = 0; i < int(n); ++i) {
    for (int j = 0; j < int(m); ++j) {
      scanf("%d", &f[i][j]);
      sum[i][j] = f[i][j];
      if (i > 0) sum[i][j] += sum[i - 1][j];
      if (j > 0) sum[i][j] += sum[i][j - 1];
      if (i > 0 && j > 0) sum[i][j] -= sum[i - 1][j - 1];
    }
  }
  for (int i = 0; i < int(n); ++i) {
    H = T = 0;
    for (int j = 0; j < int(b); ++j) add(f[i][j], j);
    for (int j = 0; j + b <= m; ++j) {
      m1[i][j] = getMin();
      if (j + b < m) {
        pop(j);
        add(f[i][j + b], j + b);
      }
    }
  }
  for (int j = 0; j < int(m); ++j) {
    H = T = 0;
    for (int i = 0; i < int(a); ++i) add(m1[i][j], i);
    for (int i = 0; i + a <= n; ++i) {
      m2[i][j] = getMin();
      if (i + a < n) {
        pop(i);
        add(m1[i + a][j], i + a);
      }
    }
  }
  for (int i = 0; i < int(n); ++i)
    for (int j = 0; j < int(m); ++j) {
      if (i + a > n || j + b > m) continue;
      long long s = getSum(i, j, i + a - 1, j + b - 1);
      t[szt++] = pl(s - m2[i][j] * 1ll * a * 1ll * b, i, j);
    }
  sort(t, t + szt);
  ans = 0;
  for (int i = 0; i < int(szt); ++i) {
    if (used[t[i].sx][t[i].sy]) continue;
    ans++;
    ina[i] = true;
    for (int x = max(0, t[i].sx - a + 1); x <= min(n - 1, t[i].sx + a - 1); ++x)
      for (int y = max(0, t[i].sy - b + 1); y <= min(m - 1, t[i].sy + b - 1);
           ++y)
        used[x][y] = true;
  }
  cout << ans << endl;
  for (int i = 0; i < int(szt); ++i)
    if (ina[i]) printf("%d %d %I64d\n", t[i].sx + 1, t[i].sy + 1, t[i].d);
  return 0;
}