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;
int h[1010][1010];
int minh_col[1010][1010];
const int inf = 1100000000;
int minh[1010][1010];
long long s[1010][1010];
long long res[1010][1010];
long long S(int i, int j) {
  long long ret = s[i + a - 1][j + b - 1];
  if (i > 0) ret -= s[i - 1][j + b - 1];
  if (j > 0) ret -= s[i + a - 1][j - 1];
  if (i > 0 && j > 0) ret += s[i - 1][j - 1];
  return ret;
}
void calc_s() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++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];
      s[i][j] += h[i][j];
    }
  }
}
void calc_res() {
  calc_s();
  long long ab = (long long)(a)*b;
  for (int i = 0; i + a - 1 < n; ++i) {
    for (int j = 0; j + b - 1 < m; ++j) {
      res[i][j] = S(i, j) - ab * minh[i][j];
    }
  }
}
struct my_q {
  vector<int> l;
  vector<int> r;
  vector<int> rr;
  int cur_min;
  my_q() { cur_min = inf; }
  void push(int x) {
    if (r.size() == 0)
      r.push_back(x);
    else
      r.push_back(min(r.back(), x));
    rr.push_back(x);
    cur_min = min(cur_min, x);
  }
  void pop() {
    if (l.size() == 0) {
      while (r.size() > 0) {
        if (l.size() == 0)
          l.push_back(rr.back());
        else
          l.push_back(min(l.back(), rr.back()));
        rr.pop_back();
        r.pop_back();
      }
    }
    l.pop_back();
    cur_min = inf;
    if (l.size() > 0) cur_min = min(cur_min, l.back());
    if (r.size() > 0) cur_min = min(cur_min, r.back());
  }
  void rel() {
    r.resize(0);
    rr.resize(0);
    l.resize(0);
    cur_min = inf;
  }
};
void calc_col() {
  my_q q;
  for (int j = 0; j < m; ++j) {
    q.rel();
    for (int i = 0; i < a; ++i) q.push(h[i][j]);
    minh_col[0][j] = q.cur_min;
    for (int i = 1; i + a - 1 < n; ++i) {
      q.push(h[i + a - 1][j]);
      q.pop();
      minh_col[i][j] = q.cur_min;
    }
  }
}
void calc_minh() {
  my_q q;
  for (int i = 0; i + a - 1 < n; ++i) {
    q.rel();
    for (int j = 0; j < b; ++j) q.push(minh_col[i][j]);
    minh[i][0] = q.cur_min;
    for (int j = 1; j + b - 1 < m; ++j) {
      q.push(minh_col[i][j + b - 1]);
      q.pop();
      minh[i][j] = q.cur_min;
    }
  }
}
struct Z {
  int i, j;
  long long s;
  bool operator<(const Z& z) const {
    if (s != z.s) return s < z.s;
    if (i != z.i) return i < z.i;
    return j < z.j;
  }
};
bool was[1010][1010];
void build(int i0, int j0) {
  for (int i = max(i0 - a + 1, 0); i <= i0 + a - 1; ++i) {
    for (int j = max(j0 - b + 1, 0); j <= j0 + b - 1; ++j) {
      was[i][j] = true;
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  scanf("%d %d", &a, &b);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", &h[i][j]);
  calc_col();
  calc_minh();
  calc_res();
  vector<Z> z;
  for (int i = 0; i + a - 1 < n; ++i) {
    for (int j = 0; j + b - 1 < m; ++j) {
      Z zz;
      zz.i = i;
      zz.j = j;
      zz.s = res[i][j];
      z.push_back(zz);
    }
  }
  vector<Z> ans;
  sort(z.begin(), z.end());
  for (int ii = 0; ii < z.size(); ++ii) {
    int i = z[ii].i;
    int j = z[ii].j;
    if (!was[i][j]) {
      ans.push_back(z[ii]);
      build(i, j);
    }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) {
    printf("%d %d %lld\n", ans[i].i + 1, ans[i].j + 1, ans[i].s);
  }
  return 0;
}