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 int MX = 1003;
int ans[MX * MX][2];
int a[MX][MX], bit[MX][MX];
int cm[MX][MX], mn[MX][MX];
;
long long cs[MX][MX], sum[MX][MX];
pair<long long, pair<int, int>> ar[MX * MX];
void upd(int i, int j, int n, int m) {
  while (i <= n) {
    int k = j;
    while (k <= m) {
      bit[i][k]++;
      k += k & -k;
    }
    i += i & -i;
  }
}
int qry(int i, int j) {
  int s = 0;
  while (i > 0) {
    int k = j;
    while (k > 0) {
      s += bit[i][k];
      k -= k & -k;
    }
    i -= i & -i;
  }
  return s;
}
int summ(int u, int l, int d, int r) {
  int x = qry(d, r);
  x -= qry(d, l - 1) + qry(u - 1, r);
  return x + qry(u - 1, l - 1);
}
void col_min(int n, int c, int k) {
  deque<int> q;
  for (int i = 0; i < n; i++) {
    if (!q.empty() && q.front() <= i - k) q.pop_front();
    while (!q.empty() && a[q.back()][c] > a[i][c]) q.pop_back();
    q.push_back(i);
    if (i >= k - 1) cm[i - k + 1][c] = a[q.front()][c];
  }
}
void row_min(int n, int r, int k) {
  deque<int> q;
  for (int i = 0; i < n; i++) {
    if (!q.empty() && q.front() <= i - k) q.pop_front();
    while (!q.empty() && cm[r][q.back()] > cm[r][i]) q.pop_back();
    q.push_back(i);
    if (i >= k - 1) mn[r][i - k + 1] = cm[r][q.front()];
  }
}
void calc(int n, int m, int p, int q) {
  for (int i = 0; i < m; i++) col_min(n, i, p);
  for (int i = 0; i < n; i++) row_min(m, i, q);
  for (int j = 0; j < m; j++) {
    for (int i = n - 1; i >= 0; i--) {
      cs[i][j] = (long long)a[i][j] + cs[i + 1][j];
      if (i + p < n) cs[i][j] -= a[i + p][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = m - 1; j >= 0; j--) {
      sum[i][j] = cs[i][j] + sum[i][j + 1];
      if (j + q < m) sum[i][j] -= cs[i][j + q];
    }
  }
}
int main() {
  int n, m, p, q, k = 0, l = 0;
  scanf("%d %d %d %d", &n, &m, &p, &q);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  calc(n, m, p, q);
  for (int i = 0; i + p <= n; i++) {
    for (int j = 0; j + q <= m; j++) {
      long long c = sum[i][j] - (long long)(p * q) * (long long)mn[i][j];
      ar[l++] = {c, {i, j}};
    }
  }
  sort(ar, ar + l);
  for (int z = 0; z < l; z++) {
    pair<long long, pair<int, int>> pr = ar[z];
    int i = pr.second.first;
    int j = pr.second.second;
    int v = summ(i + 1, j + 1, i + p, j + q);
    if (v == 0) {
      ans[k][0] = i;
      ans[k++][1] = j;
      upd(i + 1, j + 1, n, m);
      upd(i + 1, j + q, n, m);
      upd(i + p, j + 1, n, m);
      upd(i + p, j + q, n, m);
    }
  }
  printf("%d\n", k);
  for (int z = 0; z < k; z++) {
    int i = ans[z][0], j = ans[z][1];
    long long c = sum[i][j] - (long long)(p * q) * (long long)mn[i][j];
    printf("%d %d %lld\n", i + 1, j + 1, c);
  }
  return 0;
}