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 mod = (long long)(1e9 + 7);
long long modpow(long long a, long long b) {
  if (!b) return 1;
  a %= mod;
  return modpow(a * a % mod, b / 2) * (b & 1 ? a : 1) % mod;
}
struct bit {
  static const int maxn = 1000;
  long long BIT[maxn][maxn];
  bit() {
    for (int i = 0; i < maxn; i++)
      for (int j = 0; j < maxn; j++) BIT[i][j] = 0LL;
  }
  void add(int i, int j, long long value) {
    for (int x = i; x < maxn; x |= x + 1)
      for (int y = j; y < maxn; y |= y + 1) BIT[x][y] += value;
  }
  long long sum(int i, int j) {
    long long ans = 0;
    for (int r = i; r >= 0; r = (r & (r + 1)) - 1)
      for (int c = j; c >= 0; c = (c & (c + 1)) - 1) ans += BIT[r][c];
    return ans;
  }
  long long sum(int x1, int y1, int x2, int y2) {
    return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) +
           sum(x1 - 1, y1 - 1);
  }
};
struct min_seg_tree {
  static const int N = int(1000);
  int n;
  int t[2 * N];
  min_seg_tree(int n) {
    this->n = n;
    memset(t, 0, sizeof(t));
  }
  void build(int arr[]) {
    for (int i = 0; i < n; i++) t[i + n] = arr[i];
    for (int i = n - 1; i >= 0; i--)
      if (i) t[i] = min(t[i << 1], t[i << 1 | 1]);
  }
  void change(int p, int v) {
    for (t[p += n] = v; p > 1; p >>= 1) t[p >> 1] = min(t[p], t[p ^ 1]);
  }
  int query(int l, int r) {
    int ans = int(1e9 + 1);
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) ans = min(ans, t[l++]);
      if (r & 1) ans = min(ans, t[--r]);
    }
    return ans;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  int a, b;
  scanf("%d", &a);
  scanf("%d", &b);
  int arr[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &arr[i][j]);
  bit bittree;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) bittree.add(i, j, arr[i][j]);
  min_seg_tree *rows[n];
  for (int i = 0; i < n; i++) {
    rows[i] = new min_seg_tree(m);
    rows[i]->build(arr[i]);
  }
  min_seg_tree *cols[m];
  for (int j = 0; j < m; j++) {
    cols[j] = new min_seg_tree(n);
    for (int i = 0; i < n; i++) cols[j]->change(i, rows[i]->query(j, j + b));
  }
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      pq;
  bool vis[n][m];
  memset(vis, false, sizeof(vis));
  for (int i = 0; i < n - a + 1; i++)
    for (int j = 0; j < m - b + 1; j++) {
      pq.push(pair<long long, int>(bittree.sum(i, j, i + a - 1, j + b - 1) -
                                       1LL * a * b * cols[j]->query(i, i + a),
                                   i * m + j));
    }
  vector<pair<long long, int> > res;
  while (!pq.empty()) {
    pair<long long, int> pp = pq.top();
    pq.pop();
    int i = pp.second / m, j = pp.second % m;
    if (!vis[i][j]) {
      res.push_back(pp);
      for (int x = max(0, i - a + 1); x < i + a; x++)
        for (int y = max(0, j - b + 1); y < j + b; y++) vis[x][y] = true;
    }
  }
  stringstream ss;
  ss << res.size() << endl;
  for (pair<long long, int> pp : res)
    ss << pp.second / m + 1 << " " << pp.second % m + 1 << " " << pp.first
       << endl;
  printf("%s", ss.str().c_str());
  return 0;
}