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], csh[1001][1001];
long long cs[1001][1001];
multiset<int> s;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
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];
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) {
    while (!q.empty()) q.pop();
    for (int _n((m)-1), j(0); j <= _n; ++j) {
      next_int(mas[i][j]);
      q.push(make_pair(mas[i][j], j));
      int rr = 0;
      while (1) {
        if (q.top().second <= j - b) {
          q.pop();
          continue;
        }
        rr = q.top().first;
        break;
      }
      csh[i][j] = rr;
      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;
  for (int _n((m)-1), j(0); j <= _n; ++j) {
    while (!q.empty()) q.pop();
    for (int _n((n)-1), i(0); i <= _n; ++i) {
      q.push(make_pair(csh[i][j], i));
      c = 0;
      while (1) {
        if (q.top().second <= i - a) {
          q.pop();
          continue;
        }
        c = q.top().first;
        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);
  }
}