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;
int slow_read() {
  int x;
  int f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  x *= f;
  return x;
}
const long long maxn = 1000 + 5;
long long h[maxn][maxn];
long long st[maxn][maxn];
char visited[maxn][maxn];
long long pre[maxn][maxn];
long long query(long long l, long long r, long long a, long long b) {
  return pre[l + a - 1][r + b - 1] + pre[l - 1][r - 1] - pre[l - 1][r + b - 1] -
         pre[l + a - 1][r - 1];
}
int main() {
  long long n, m, a, b;
  n = slow_read();
  m = slow_read();
  a = slow_read();
  b = slow_read();
  for (register int i = 1; i <= n; ++i) {
    for (register int j = 1; j <= m; ++j) {
      h[i][j] = slow_read();
    }
  }
  for (register int i = 1; i <= n; ++i) {
    long long tmp = 0;
    for (register int j = 1; j <= m; ++j) {
      tmp += h[i][j];
      pre[i][j] = pre[i - 1][j] + tmp;
    }
  }
  for (register int i = 1; i <= n; ++i) {
    for (register int j = 1; j <= m; ++j) {
      st[i][j] = h[i][j];
    }
  }
  vector<pair<long long, long long> > vt;
  vt.push_back(make_pair(a, b));
  while (true) {
    long long x = vt.back().first;
    long long y = vt.back().second;
    x = (x + 1) / 2;
    y = (y + 1) / 2;
    if (x == 1 && y == 1) {
      break;
    }
    vt.push_back(make_pair(x, y));
  }
  while (!vt.empty()) {
    long long x = vt.back().first;
    long long y = vt.back().second;
    long long prex = (x + 1) / 2;
    long long prey = (y + 1) / 2;
    vt.pop_back();
    for (register int i = 1; i <= n - x + 1; ++i) {
      for (register int j = 1; j <= m - y + 1; ++j) {
        st[i][j] = min(st[i][j], st[i + x - prex][j]);
        st[i][j] = min(st[i][j], st[i][j + y - prey]);
        st[i][j] = min(st[i][j], st[i + x - prex][j + y - prey]);
      }
    }
  }
  long long Ans = 0;
  vector<pair<long long, long long> > vt1;
  vector<long long> vt2;
  vector<pair<long long, long long> > tv;
  for (register int i = n - a + 1; i >= 1; --i) {
    for (register int j = m - b + 1; j >= 1; --j) {
      long long ans = query(i, j, a, b) - st[i][j] * (a * b);
      tv.push_back(make_pair(-ans, -(i * maxn + j)));
    }
  }
  sort(tv.begin(), tv.end());
  while (true) {
    if (tv.empty()) {
      printf("%I64d\n", Ans);
      for (long long i = 0, j = vt1.size(); i < j; ++i) {
        printf("%I64d %I64d %I64d\n", vt1[i].first, vt1[i].second, vt2[i]);
      }
      return 0;
    }
    pair<long long, long long> tmp = tv.back();
    long long mina = (-tmp.second) / maxn;
    long long minb = (-tmp.second) - mina * maxn;
    tv.pop_back();
    if (visited[mina][minb]) {
      continue;
    }
    long long minn = -tmp.first;
    long long la = max(1ll, mina - a + 1);
    long long lb = max(1ll, minb - b + 1);
    long long ra = mina + a - 1;
    long long rb = minb + b - 1;
    for (register int i = la; i <= ra; ++i) {
      for (register int j = lb; j <= rb; ++j) {
        visited[i][j] = 1;
      }
    }
    ++Ans;
    vt1.push_back(make_pair(mina, minb));
    vt2.push_back(minn);
  }
  return 0;
}