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>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
int n, m;
int a, b;
int h[1005][1005];
int d[1005][13];
long long mn[1005][1005], mn2[1005][1005];
long long sum[1005][1005], s[1005][1005];
long long w[1005][1005];
bool used[1005][1005];
pair<int, int> p[1005 * 1005];
pair<int, int> ans[1005 * 1005];
bool Cmp(pair<int, int> p1, pair<int, int> p2) {
  if (w[p1.first][p1.second] != w[p2.first][p2.second])
    return w[p1.first][p1.second] < w[p2.first][p2.second];
  return p1 < p2;
}
int main() {
  scanf("%d %d %d %d", &n, &m, &a, &b);
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(m); j++) {
      scanf("%d", &h[i][j]);
    }
  }
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(m); j++) {
      d[j][0] = h[i][j];
    }
    for (int k = 1; k <= int(13 - 1); k++) {
      for (int j = 0; j < int(m); j++) {
        d[j][k] = d[j][k - 1];
        if (j + (1 << (k - 1)) < m) {
          d[j][k] = min(d[j][k], d[j + (1 << (k - 1))][k - 1]);
        }
      }
    }
    int t = 0;
    while ((1 << (t + 1)) < b) t++;
    for (int j = 0; j < int(m - b + 1); j++) {
      mn[i][j] = min(d[j][t], d[j + b - (1 << t)][t]);
    }
  }
  for (int j = 0; j < int(m - b + 1); j++) {
    for (int i = 0; i < int(n); i++) {
      d[i][0] = mn[i][j];
    }
    for (int k = 1; k <= int(13 - 1); k++) {
      for (int i = 0; i < int(n); i++) {
        d[i][k] = d[i][k - 1];
        if (i + (1 << (k - 1)) < n) {
          d[i][k] = min(d[i][k], d[i + (1 << (k - 1))][k - 1]);
        }
      }
    }
    int t = 0;
    while ((1 << (t + 1)) < a) t++;
    for (int i = 0; i < int(n - a + 1); i++) {
      mn2[i][j] = min(d[i][t], d[i + a - (1 << t)][t]);
    }
  }
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(m); j++) {
      s[i + 1][j + 1] = s[i + 1][j] + s[i][j + 1] + h[i][j] - s[i][j];
    }
  }
  for (int i = 0; i < int(n - a + 1); i++) {
    for (int j = 0; j < int(m - b + 1); j++) {
      sum[i][j] = s[i + a][j + b] - s[i][j + b] - s[i + a][j] + s[i][j];
    }
  }
  int cnt = 0;
  for (int i = 0; i < int(n - a + 1); i++) {
    for (int j = 0; j < int(m - b + 1); j++) {
      w[i][j] = sum[i][j] - mn2[i][j] * a * b;
      p[cnt] = make_pair(i, j);
      cnt++;
    }
  }
  sort(p, p + cnt, Cmp);
  int sz = 0;
  for (int it = 0; it < int(cnt); it++) {
    int i = p[it].first;
    int j = p[it].second;
    if (used[i][j]) continue;
    ans[sz] = p[it];
    sz++;
    for (int x = max(i - a + 1, 0); x < i + a; x++) {
      for (int y = max(j - b + 1, 0); y < j + b; y++) {
        used[x][y] = true;
      }
    }
  }
  cout << sz << endl;
  for (int i = 0; i < int(sz); i++) {
    printf("%d %d %I64d\n", ans[i].first + 1, ans[i].second + 1,
           w[ans[i].first][ans[i].second]);
  }
  return 0;
}