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;
inline long long read() {
  char c;
  long long flag = 1;
  while ((c = getchar()) < '0' || c > '9') {
    if (c == '-') {
      flag = -1;
    }
  }
  long long count = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') {
    count *= 10;
    count += c - '0';
  }
  return count * flag;
}
inline void print(long long x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x > 9) {
    print(x / 10);
  }
  putchar(x % 10 + '0');
}
const long long N = 1010;
struct Node {
  long long x;
  long long t;
  bool operator>(Node a) const { return x > a.x; }
  bool operator<(Node a) const { return x < a.x; }
};
struct Edge {
  long long x;
  long long y;
  long long t;
} edge[N * N], ans[N * N];
priority_queue<Node, vector<Node>, greater<Node> > q;
long long h[N][N];
long long g[N][N];
long long A[N][N], s[N][N];
bool book[N][N];
inline bool cmp_Edge(Edge a, Edge b) {
  if (a.t == b.t) {
    if (a.x == b.x) {
      return a.y < b.y;
    }
    return a.x < b.x;
  }
  return a.t < b.t;
}
signed main() {
  long long n, m, a, b;
  n = read(), m = read();
  a = read(), b = read();
  for (register long long i = 1; i <= n; i++) {
    for (register long long j = 1; j <= m; j++) {
      A[i][j] = read();
      s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + A[i][j];
    }
  }
  for (register long long i = 1; i <= n; i++) {
    while (!q.empty()) {
      q.pop();
    }
    for (register long long j = m; j >= 1; j--) {
      q.push((Node){A[i][j], j});
      if (j >= m - b + 2) {
        continue;
      }
      while (q.top().t >= j + b) {
        q.pop();
      }
      h[i][j] = q.top().x;
    }
  }
  for (register long long j = 1; j <= m; j++) {
    while (!q.empty()) {
      q.pop();
    }
    for (register long long i = n; i >= 1; i--) {
      q.push((Node){h[i][j], i});
      if (i >= n - a + 2) {
        continue;
      }
      while (q.top().t >= i + a) {
        q.pop();
      }
      h[i][j] = min(h[i][j], q.top().x);
    }
  }
  long long tot = 0;
  for (register long long i = 1; i <= n - a + 1; i++) {
    for (register long long j = 1; j <= m - b + 1; j++) {
      long long sx = i, sy = j;
      long long ex = i + a - 1, ey = j + b - 1;
      long long count =
          s[ex][ey] - s[ex][sy - 1] - s[sx - 1][ey] + s[sx - 1][sy - 1];
      tot++;
      edge[tot].x = i;
      edge[tot].y = j;
      edge[tot].t = count - h[sx][sy] * a * b;
    }
  }
  sort(edge + 1, edge + tot + 1, cmp_Edge);
  long long cnt = 0;
  for (register long long i = 1; i <= tot; i++) {
    long long sx = edge[i].x;
    long long sy = edge[i].y;
    long long ex = sx + a - 1;
    long long ey = sy + b - 1;
    if (book[sx][sy] == 1 || book[sx][ey] == 1 || book[ex][sy] ||
        book[ex][ey] == 1) {
      continue;
    }
    for (register long long j = sx; j <= ex; j++) {
      for (register long long k = sy; k <= ey; k++) {
        book[j][k] = 1;
      }
    }
    cnt++;
    ans[cnt] = edge[i];
  }
  print(cnt);
  putchar('\n');
  for (register long long i = 1; i <= cnt; i++) {
    print(ans[i].x);
    putchar(' ');
    print(ans[i].y);
    putchar(' ');
    print(ans[i].t);
    putchar('\n');
  }
  return 0;
}