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;
const long long MAX_N = 1000 + 10;
long long n, m, a, b;
long long tab[MAX_N][MAX_N];
long long sum[MAX_N][MAX_N];
void input() {
  cin >> n >> m >> a >> b;
  for (long long i = 0; i < (n); i++)
    for (long long j = 0; j < (m); j++) {
      int val;
      scanf("%d", &val);
      tab[i][j] = val;
      sum[i][j] = tab[i][j];
      if (i) sum[i][j] += sum[i - 1][j];
      if (j) sum[i][j] += sum[i][j - 1];
      if (i && j) sum[i][j] -= sum[i - 1][j - 1];
    }
}
long long inp[MAX_N];
long long out[MAX_N];
pair<long long, long long> stk[MAX_N];
void calmin(long long n, long long k) {
  long long head = 0, tail = 0;
  for (long long i = 0; i < (n); i++) {
    while (head < tail && stk[tail - 1].first > inp[i]) tail--;
    stk[tail++] = pair<long long, long long>(inp[i], i);
    while (head < tail && stk[head].second + k <= i) head++;
    out[i] = stk[head].first;
  }
}
bool mark[MAX_N][MAX_N];
vector<pair<long long, pair<long long, long long> > > site;
void solve() {
  for (long long i = n - 1; i >= 0; i--)
    for (long long j = m - 1; j >= 0; j--) {
      if (i - a >= 0) sum[i][j] -= sum[i - a][j];
      if (j - b >= 0) sum[i][j] -= sum[i][j - b];
      if (i - a >= 0 && j - b >= 0) sum[i][j] += sum[i - a][j - b];
    }
  for (long long i = 0; i < (n); i++) {
    copy(tab[i], tab[i] + m, inp);
    calmin(m, b);
    copy(out, out + m, tab[i]);
  }
  for (long long j = 0; j < (m); j++) {
    for (long long i = 0; i < (n); i++) inp[i] = tab[i][j];
    calmin(n, a);
    for (long long i = 0; i < (n); i++) tab[i][j] = out[i];
  }
  for (long long i = 0; i < (n); i++)
    for (long long j = 0; j < (m); j++)
      if (a - 1 <= i && b - 1 <= j) {
        site.push_back(
            make_pair(sum[i][j] - tab[i][j] * a * b,
                      pair<long long, long long>(i - (a - 1), j - (b - 1))));
      }
  sort(site.begin(), site.end());
  long long head = 0;
  for (long long k = 0; k < (((long long)site.size())); k++) {
    long long r = site[k].second.first;
    long long c = site[k].second.second;
    if (mark[r][c]) continue;
    for (long long i = max(0ll, r - a + 1); i < min(r + a, n); i++)
      for (long long j = max(0ll, c - b + 1); j < min(c + b, m); j++)
        mark[i][j] = true;
    site[head++] = site[k];
  }
  ios::sync_with_stdio(false);
  cout << head << endl;
  for (long long i = 0; i < (head); i++)
    cout << ((int)site[i].second.first + 1) << " "
         << ((int)site[i].second.second + 1) << " " << site[i].first << endl;
}
int main() {
  input();
  solve();
  return 0;
}