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 n, m;
int a, b;
void Sumy(vector<vector<long long> >& p, vector<vector<long long> >& sumy) {
  vector<vector<long long> > s(n, vector<long long>(m, 0));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      s[i][j] = p[i][j];
      if (i != 0) s[i][j] += s[i - 1][j];
      if (j != 0) s[i][j] += s[i][j - 1];
      if (i != 0 && j != 0) s[i][j] -= s[i - 1][j - 1];
      if (i + 1 >= a && j + 1 >= b) {
        sumy[i][j] = s[i][j];
        if (i != a - 1) sumy[i][j] -= s[i - a][j];
        if (j != b - 1) sumy[i][j] -= s[i][j - b];
        if (i != a - 1 && j != b - 1) sumy[i][j] += s[i - a][j - b];
      }
    }
  }
}
void Miny(vector<vector<long long> >& p, vector<vector<long long> >& miny) {
  vector<vector<long long> > poz(n, vector<long long>(m, 0));
  for (int i = 0; i < n; ++i) {
    multiset<long long> S;
    for (int j = 0; j < m; ++j) {
      if (j + 1 <= b)
        S.insert(p[i][j]);
      else {
        S.erase(S.find(p[i][j - b]));
        S.insert(p[i][j]);
      }
      if (j + 1 >= b) poz[i][j] = *S.begin();
    }
  }
  vector<vector<long long> > pio(n, vector<long long>(m, 0));
  for (int j = 0; j < m; ++j) {
    if (j + 1 >= b) {
      multiset<long long> S;
      for (int i = 0; i < n; ++i) {
        if (i + 1 <= a)
          S.insert(poz[i][j]);
        else {
          S.erase(S.find(poz[i - a][j]));
          S.insert(poz[i][j]);
        }
        if (i + 1 >= a) pio[i][j] = *S.begin();
      }
    }
  }
  miny = pio;
}
int main() {
  scanf("%d %d %d %d", &n, &m, &a, &b);
  vector<vector<long long> > p(n, vector<long long>(m));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%I64d", &p[i][j]);
  vector<vector<long long> > sumy(n, vector<long long>(m, 0));
  Sumy(p, sumy);
  vector<vector<long long> > miny(n, vector<long long>(m));
  Miny(p, miny);
  vector<vector<long long> > W(n, vector<long long>(m, 0));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (i + a - 1 <= n - 1 && j + b - 1 <= m - 1)
        W[i][j] =
            sumy[i + a - 1][j + b - 1] - a * b * miny[i + a - 1][j + b - 1];
  vector<pair<long long, pair<int, int> > > S;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (i + a - 1 <= n - 1 && j + b - 1 <= m - 1)
        S.push_back(make_pair(W[i][j], make_pair(i, j)));
  sort(S.begin(), S.end());
  vector<pair<int, pair<int, long long> > > odp;
  vector<vector<bool> > bylo(n, vector<bool>(m, false));
  for (int akt = 0; akt < S.size(); ++akt) {
    pair<long long, pair<int, int> > t = S[akt];
    int x = t.second.first;
    int y = t.second.second;
    long long usu = t.first;
    if (bylo[x][y]) continue;
    for (int i = max(0, x - a + 1); i <= x + a - 1; ++i)
      for (int j = max(0, y - b + 1); j <= y + b - 1; ++j) bylo[i][j] = true;
    odp.push_back(make_pair(x, make_pair(y, usu)));
  }
  printf("%d\n", odp.size());
  for (int i = 0; i < odp.size(); ++i)
    printf("%d %d %I64d\n", odp[i].first + 1, odp[i].second.first + 1,
           odp[i].second.second);
  return 0;
}