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;
long long S[1024][1024];
pair<long long, pair<int, int> > c[1024 * 1024];
int k;
int mas[1024][1024];
int n, m;
int sum_1based(int y1, int x1, int y2, int x2) {
  if (y2 < 0 || x2 < 0) return 0;
  if (y1 == 1 && x1 == 1) {
    static int r;
    r = 0;
    for (y1 = y2; y1; y1 = (y1 & (y1 - 1)))
      for (x1 = x2; x1; x1 = (x1 & (x1 - 1))) r += mas[y1][x1];
    return r;
  } else
    return sum_1based(1, 1, y2, x2) - sum_1based(1, 1, y1 - 1, x2) -
           sum_1based(1, 1, y2, x1 - 1) + sum_1based(1, 1, y1 - 1, x1 - 1);
}
int sum(int y1, int x1, int y2, int x2) {
  return sum_1based(y1 + 1, x1 + 1, y2 + 1, x2 + 1);
}
void modify(int y, int x) {
  y++;
  x++;
  static int yy, xx;
  for (yy = y; yy <= n; yy = ((yy << 1) - ((yy & (yy - 1)))))
    for (xx = x; xx <= m; xx = ((xx << 1) - ((xx & (xx - 1))))) mas[yy][xx]++;
}
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >,
               greater<pair<int, pair<int, int> > > >
    ph[1024];
int main() {
  int a, b;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  int yo = 0;
  for (int i = (0), _b(n); i < _b; ++i) {
    priority_queue<pair<int, pair<int, int> >,
                   vector<pair<int, pair<int, int> > >,
                   greater<pair<int, pair<int, int> > > >
        p;
    for (int j = (0), _b(m); j < _b; ++j) {
      scanf("%I64d", &S[i + 1][j + 1]);
      ph[j].push(make_pair(S[i + 1][j + 1], pair<int, int>(j, i)));
      S[i + 1][j + 1] = S[i + 1][j + 1] + S[i][j + 1] + S[i + 1][j] - S[i][j];
      if (i >= a - 1) {
        while (ph[j].top().second.second <= i - a) ph[j].pop();
        p.push(ph[j].top());
        if (j >= b - 1) {
          while (p.top().second.first <= j - b) p.pop();
          c[yo++].first -= (long long)p.top().first * a * b;
        }
      }
    }
  }
  for (int i = (0), _b(n - a + 1); i < _b; ++i)
    for (int j = (0), _b(m - b + 1); j < _b; ++j) {
      c[k].first += S[i + a][j + b] + S[i][j] - S[i + a][j] - S[i][j + b];
      c[k].second.first = i;
      c[k].second.second = j;
      ++k;
    }
  sort(c, c + k);
  int lenans = 0;
  for (int i = (0), _b(k); i < _b; ++i) {
    if (sum(c[i].second.first, c[i].second.second, c[i].second.first + a - 1,
            c[i].second.second + b - 1))
      continue;
    for (int q = (0), _b(a); q < _b; ++q)
      for (int w = (0), _b(b); w < _b; ++w)
        modify(c[i].second.first + q, c[i].second.second + w);
    c[lenans++] = c[i];
  }
  printf("%d\n", lenans);
  for (int i = (0), _b(lenans); i < _b; ++i)
    printf("%d %d %I64d\n", c[i].second.first + 1, c[i].second.second + 1,
           c[i].first);
  return 0;
}