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>
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
void slide(int *aa, int n, int k) {
  static int qu[1000];
  int i, head, cnt;
  head = cnt = 0;
  for (i = 0; i < n; i++) {
    while (cnt && aa[qu[head + cnt - 1]] >= aa[i]) cnt--;
    qu[head + cnt++] = i;
    if (i >= k - 1) {
      aa[i - k + 1] = aa[qu[head]];
      if (cnt && qu[head] == i - k + 1) head++, cnt--;
    }
  }
}
long long bb[1000][1000];
int n, m;
int compare(const void *a, const void *b) {
  int h1 = *(int *)a;
  int h2 = *(int *)b;
  long long x = bb[h1 / m][h1 % m];
  long long y = bb[h2 / m][h2 % m];
  return x == y ? h1 - h2 : x < y ? -1 : 1;
}
int main() {
  static int aa[1000][1000], rr[1000], cc[1000], hh[1000 * 1000];
  static long long pp[1000 + 1][1000 + 1];
  static char bad[1000][1000];
  int a, b, h, i, j, cnt;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      scanf("%d", &aa[i][j]);
      pp[i][j] = aa[i][j];
    }
  for (i = n - 1; i >= 0; i--)
    for (j = m - 1; j >= 0; j--) pp[i][j] += pp[i][j + 1];
  for (j = m - 1; j >= 0; j--)
    for (i = n - 1; i >= 0; i--) pp[i][j] += pp[i + 1][j];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) rr[j] = aa[i][j];
    slide(rr, m, b);
    for (j = 0; j + b <= m; j++) aa[i][j] = rr[j];
  }
  m -= b - 1;
  for (j = 0; j < m; j++) {
    for (i = 0; i < n; i++) cc[i] = aa[i][j];
    slide(cc, n, a);
    for (i = 0; i + a <= n; i++) aa[i][j] = cc[i];
  }
  n -= a - 1;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      bb[i][j] = pp[i][j] - pp[i + a][j] - pp[i][j + b] + pp[i + a][j + b] -
                 (long long)aa[i][j] * a * b;
  for (h = 0; h < n * m; h++) hh[h] = h;
  qsort(hh, n * m, sizeof *hh, compare);
  cnt = 0;
  for (h = 0; h < n * m; h++) {
    i = hh[h] / m, j = hh[h] % m;
    if (!bad[i][j]) {
      int il, jl, ir, jr;
      hh[cnt++] = hh[h];
      il = max(i - a + 1, 0), jl = max(j - b + 1, 0);
      ir = min(i + a - 1, n - 1), jr = min(j + b - 1, m - 1);
      for (i = il; i <= ir; i++)
        for (j = jl; j <= jr; j++) bad[i][j] = 1;
    }
  }
  printf("%d\n", cnt);
  for (h = 0; h < cnt; h++) {
    i = hh[h] / m, j = hh[h] % m;
    printf("%d %d %lld\n", i + 1, j + 1, bb[i][j]);
  }
  return 0;
}