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;
int v[1000][1000], vis[1000][1000];
int dp[1000][1000][10];
int po[10], vr[2 * 1000], vl[1000], ar[4 * 1000];
long long int sum[1000][1000];
void build(int l, int h, int p) {
  if (l == h)
    ar[p] = vl[l];
  else {
    int q = (l + h) / 2;
    build(l, q, 2 * p + 1);
    build(q + 1, h, 2 * p + 2);
    ar[p] = min(ar[2 * p + 1], ar[2 * p + 2]);
  }
  return;
}
int c, d;
int query(int l, int h, int p) {
  if (c > h || d < l) return 1e9;
  if (c <= l && d >= h) return ar[p];
  int q = (l + h) / 2;
  return min(query(l, q, 2 * p + 1), query(q + 1, h, 2 * p + 2));
}
int main() {
  int n, m, i, j, k, p, q, a, b, x, z;
  scanf("%d", &n), scanf("%d", &m), scanf("%d", &a), scanf("%d", &b);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &v[i][j]);
      sum[i][j] = v[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];
    }
  }
  vr[1] = 0, k = 1, po[0] = 1;
  while (k < 1000) {
    for (i = k + 1; i < 2 * k; i++) vr[i] = vr[k];
    vr[2 * k] = 1 + vr[k], k *= 2;
  }
  x = 1 + vr[n];
  for (i = 1; i < 10; i++) po[i] = 2 * po[i - 1];
  for (j = 0; j < m; j++) {
    for (i = 0; i < n; i++) dp[j][i][0] = v[i][j];
    for (k = 1; k < x; k++) {
      for (i = 0; i + po[k] <= n; i++)
        dp[j][i][k] = min(dp[j][i][k - 1], dp[j][i + po[k - 1]][k - 1]);
    }
  }
  k = (n - a + 1) * (m - b + 1);
  vector<pair<long long int, pair<int, int> > > vp(k), ans(k);
  long long int t, tp;
  k = 0;
  for (i = 0; i + a <= n; i++) {
    z = vr[a], c = a - po[z];
    for (j = 0; j < m; j++) vl[j] = min(dp[j][i][z], dp[j][i + c][z]);
    for (j = 0; j < 4 * 1000; j++) ar[j] = 0;
    build(0, m - 1, 0);
    for (j = 0; j + b <= m; j++) {
      t = sum[i + a - 1][j + b - 1];
      if (i > 0) t -= sum[i - 1][j + b - 1];
      if (j > 0) t -= sum[i + a - 1][j - 1];
      if (i > 0 & j > 0) t += sum[i - 1][j - 1];
      c = j, d = j + b - 1;
      x = query(0, m - 1, 0);
      tp = x, tp *= a, tp *= b;
      vp[k].first = t - tp, vp[k].second.first = i, vp[k].second.second = j;
      k++;
    }
  }
  x = 0;
  sort(vp.begin(), vp.end());
  for (z = 0; z < k; z++) {
    i = vp[z].second.first, j = vp[z].second.second;
    if (!vis[i][j]) {
      ans[x].first = vp[z].first, ans[x].second.first = 1 + vp[z].second.first,
      ans[x].second.second = 1 + vp[z].second.second;
      x++, c = min(n, i + a), d = min(m, j + b);
      for (p = max(0, i - a + 1); p < c; p++) {
        for (q = max(0, j - b + 1); q < d; q++) vis[p][q] = 1;
      }
    }
  }
  printf("%d\n", x);
  for (i = 0; i < x; i++)
    printf("%d ", ans[i].second.first), printf("%d ", ans[i].second.second),
        printf("%I64d\n", ans[i].first);
  return 0;
}