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 long long INF = 1e9 + 7;
struct hhh {
  long long x;
  long long y;
  long long v;
} c[1000001];
bool operator<(hhh a, hhh b) {
  return (a.v != b.v ? a.v > b.v : (a.x != b.x ? a.x > b.x : a.y > b.y));
}
vector<hhh> v;
long long n, m, a, b, h[1001][1001], g[1001][1001], mi[1001][1001],
    minf[1001][1001], k;
bool f[1001][1001];
long long pre[3][1001][1001];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
bool check(hhh t) {
  if (f[t.x][t.y]) {
    return 0;
  }
  for (long long i = max(t.x - a + 1, (long long)1); i <= t.x + a - 1; i++) {
    for (long long j = max(t.y - b + 1, (long long)1); j <= t.y + b - 1; j++) {
      f[i][j] = 1;
    }
  }
  return 1;
}
int main() {
  n = read();
  m = read();
  a = read();
  b = read();
  for (long long i = 1; i <= (n); i++) {
    for (long long j = 1; j <= (m); j++) {
      h[i][j] = read();
    }
  }
  for (long long i = 1; i <= (n); i++) {
    for (long long j = 1; j <= (m); j++) {
      pre[1][i][j] = pre[1][i][j - 1] + h[i][j];
      pre[2][i][j] = pre[2][i - 1][j] + h[i][j];
    }
  }
  for (long long i = 1; i <= (a); i++) {
    g[1][1] += pre[1][i][b];
  }
  for (long long i = 2; i <= m - b + 1; i++) {
    g[1][i] = g[1][i - 1] + pre[2][a][i + b - 1] - pre[2][a][i - 1];
  }
  for (long long i = 2; i <= n - a + 1; i++) {
    for (long long j = 1; j <= (m - b + 1); j++) {
      g[i][j] = g[i - 1][j] + pre[1][i + a - 1][j + b - 1] -
                pre[1][i + a - 1][j - 1] - pre[1][i - 1][j + b - 1] +
                pre[1][i - 1][j - 1];
    }
  }
  for (long long i = 1; i <= (n); i++) {
    long long s = 1;
    long long t = 0;
    long long que[1001];
    que[0] = INF;
    for (long long j = 1; j <= (m); j++) {
      while (s <= t && h[i][que[t]] >= h[i][j]) {
        t--;
      }
      que[++t] = j;
      if (j - b >= 0) {
        mi[i][j - b + 1] = h[i][que[s]];
      }
      if (que[s] == j - b + 1) {
        s++;
      }
    }
  }
  for (long long j = 1; j <= (m - b + 1); j++) {
    long long s = 1;
    long long t = 0;
    long long que[1001];
    que[0] = INF;
    for (long long i = 1; i <= (n); i++) {
      while (s <= t && mi[que[t]][j] >= mi[i][j]) {
        t--;
      }
      que[++t] = i;
      if (i - a >= 0) {
        minf[i - a + 1][j] = mi[que[s]][j];
      }
      if (que[s] == i - a + 1) {
        s++;
      }
    }
  }
  for (long long i = 1; i <= (n - a + 1); i++) {
    for (long long j = 1; j <= (m - b + 1); j++) {
      g[i][j] -= a * b * minf[i][j];
      hhh t;
      t.x = i;
      t.y = j;
      t.v = g[i][j];
      v.push_back(t);
    }
  }
  make_heap(v.begin(), v.end());
  while (!v.empty()) {
    hhh t = v.front();
    pop_heap(v.begin(), v.end());
    v.pop_back();
    if (check(t)) {
      c[++k] = t;
    }
  }
  cout << k << endl;
  for (long long i = 1; i <= (k); i++) {
    printf("%I64d %I64d %I64d\n", c[i].x, c[i].y, c[i].v);
  }
  return 0;
}