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:16777216")
using namespace std;
char *ch, buf[2049];
inline char get_char() {
  if (*ch == 0) {
    ch = buf;
    fread(buf, sizeof(char), 2048, stdin);
  }
  return *(ch++);
}
inline void next_int(int &ans) {
  ans = 0;
  char ch;
  while ((ch = get_char()) < '0' || ch > '9')
    ;
  do {
    ans = ans * 10 + ch - '0';
  } while ((ch = get_char()) >= '0' && ch <= '9');
}
int a, b, c, d, i, j, n, m, k, t, row;
int mas[1001][1001];
int mn[10][1001][1001], fn[1001][1001];
long long cs[1001][1001];
pair<long long, int> ord[1000001];
bool u[1001][1001];
inline long long sum(int i, int j) {
  if (i < 0 || j < 0)
    return 0;
  else
    return cs[i][j];
}
pair<int, long long> ans[1000001];
inline int min(int a, int b, int c, int d) {
  if (a > b) a = b;
  if (c > d) c = d;
  if (a < c)
    return a;
  else
    return c;
}
int main() {
  ch = buf;
  next_int(n);
  next_int(m);
  next_int(a);
  next_int(b);
  for (int _n((n)-1), i(0); i <= _n; ++i) {
    for (int _n((m)-1), j(0); j <= _n; ++j) {
      next_int(mas[i][j]);
      if (!i && !j)
        cs[i][j] = mas[i][j];
      else if (!i)
        cs[i][j] = mas[i][j] + cs[i][j - 1];
      else if (!j)
        cs[i][j] = mas[i][j] + cs[i - 1][j];
      else
        cs[i][j] = mas[i][j] + cs[i - 1][j] + cs[i][j - 1] - cs[i - 1][j - 1];
    }
  }
  k = 0;
  memset(mn, 63, sizeof(mn));
  d = min(a, b);
  for (int _n((10) - 1), h(0); h <= _n; ++h) {
    c = 1 << h;
    if (c > d) break;
    for (int _n(n - 1), i(c - 1); i <= _n; ++i) {
      for (int _n(m - 1), j(c - 1); j <= _n; ++j) {
        if (!h) {
          mn[h][i][j] = mas[i][j];
        } else {
          mn[h][i][j] =
              min(mn[h - 1][i][j], mn[h - 1][i - c / 2][j],
                  mn[h - 1][i][j - c / 2], mn[h - 1][i - c / 2][j - c / 2]);
        }
      }
    }
  }
  memset(fn, 63, sizeof(fn));
  c = 0;
  while ((1 << c + 1) <= d) ++c;
  for (int _n((n)-1), i(0); i <= _n; ++i) {
    for (int _n((m)-1), j(0); j <= _n; ++j) {
      fn[i][j] = min(mn[c][i][j], mn[c][i - d + (1 << c)][j],
                     mn[c][i][j - d + (1 << c)],
                     mn[c][i - d + (1 << c)][j - d + (1 << c)]);
    }
  }
  for (int _n(n - 1), i(a - 1); i <= _n; ++i) {
    for (int _n(m - 1), j(b - 1); j <= _n; ++j) {
      if (a == b)
        c = fn[i][j];
      else if (a < b) {
        c = 1000000000;
        for (int z = j - b + a;; z += a) {
          if (z > j) z = j;
          if (fn[i][z] < c) c = fn[i][z];
          if (z >= j) break;
        }
      } else {
        c = 1000000000;
        for (int z = i - a + b;; z += b) {
          if (z > i) z = i;
          if (fn[z][j] < c) c = fn[z][j];
          if (z >= i) break;
        }
      }
      long long rr = sum(i, j) - sum(i - a, j) - sum(i, j - b) +
                     sum(i - a, j - b) - (long long)c * a * b;
      ord[k++] = make_pair(rr, i * m + j);
    }
  }
  sort(ord, ord + k);
  for (int _n((k)-1), i(0); i <= _n; ++i) {
    int first = ord[i].second / m, second = ord[i].second % m;
    if (first - a + 1 < 0 || second - b + 1 < 0) continue;
    if (u[first][second] || u[first - a + 1][second - b + 1] ||
        u[first - a + 1][second] || u[first][second - b + 1])
      continue;
    for (int _n(first), z(first - a + 1); z <= _n; ++z)
      for (int _n(second), o(second - b + 1); o <= _n; ++o) u[z][o] = 1;
    ans[t++] = make_pair((first - a + 1) * m + second - b + 1, ord[i].first);
  }
  printf("%d\n", t);
  for (int _n((t)-1), i(0); i <= _n; ++i) {
    printf("%d %d %I64d\n", ans[i].first / m + 1, ans[i].first % m + 1,
           ans[i].second);
  }
}