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;
struct st {
  long long a[1111];
  long long p[1111];
  long long q[1111];
  int sz;
  st() { sz = 0; }
  inline void push(long long first) {
    a[sz] = first;
    if (sz) {
      p[sz] = std::min(a[sz], p[sz - 1]);
      q[sz] = a[sz] + q[sz - 1];
    } else {
      p[sz] = a[sz];
      q[sz] = (long long)a[sz];
    }
    sz++;
  }
  inline long long pop() {
    if (sz) --sz;
    return a[sz];
  }
  inline long long min() {
    if (sz)
      return p[sz - 1];
    else
      return 1000000000;
  }
  inline long long sum() {
    if (sz)
      return q[sz - 1];
    else
      return 0;
  }
};
struct qu {
  st a, b;
  inline void push(long long first) { a.push(first); }
  inline void pop() {
    int cp = a.sz;
    if (!b.sz)
      for (int(i) = 0; (i) < (cp); ++(i)) b.push(a.pop());
    b.pop();
  }
  inline long long min() { return std::min(a.min(), b.min()); }
  inline long long sum() { return a.sum() + b.sum(); }
  inline int sz() { return a.sz + b.sz; }
};
int a[1111][1111];
int b[1111][1111];
long long c[1111][1111];
int d[1111][1111];
long long e[1111][1111];
struct T {
  int first, second;
  long long sm;
};
inline bool operator<(const T& a, const T& b) {
  if (a.sm != b.sm) return a.sm > b.sm;
  if (a.first != b.first) return a.first > b.first;
  return a.second > b.second;
}
priority_queue<T> pq;
int n, m, dx, dy;
int tot = 0;
int px[1111111], py[1111111];
long long ps[1111111];
int main() {
  scanf("%d%d%d%d", &n, &m, &dx, &dy);
  for (int(i) = 0; (i) < (n); ++(i))
    for (int(j) = 0; (j) < (m); ++(j)) scanf("%d", &a[i][j]);
  for (int(i) = 0; (i) < (n); ++(i)) {
    qu q;
    for (int(j) = 0; (j) < (m); ++(j)) {
      q.push(a[i][j]);
      if (q.sz() > dy) q.pop();
      if (q.sz() >= dy) {
        b[i][j - dy + 1] = (int)q.min();
        c[i][j - dy + 1] = q.sum();
      }
    }
  }
  for (int(j) = 0; (j) < (m - dy + 1); ++(j)) {
    qu qm;
    qu qs;
    for (int(i) = 0; (i) < (n); ++(i)) {
      qm.push(b[i][j]);
      qs.push(c[i][j]);
      if (qm.sz() > dx) {
        qm.pop();
        qs.pop();
      }
      if (qm.sz() >= dx) {
        T e;
        e.first = i - dx + 1;
        e.second = j;
        e.sm = qs.sum() - (long long)dx * dy * qm.min();
        pq.push(e);
      }
    }
  }
  while (!pq.empty()) {
    T cur = pq.top();
    pq.pop();
    if (a[cur.first][cur.second] == -1) continue;
    px[tot] = cur.first + 1;
    py[tot] = cur.second + 1;
    ps[tot++] = cur.sm;
    int sti = max(0, cur.first - dx + 1);
    int fni = min(cur.first + dx, n);
    int stj = max(0, cur.second - dy + 1);
    int fnj = min(cur.second + dy, m);
    for (int i = sti; i < fni; ++i)
      for (int j = stj; j < fnj; ++j) a[i][j] = -1;
  }
  printf("%d\n", tot);
  for (int(i) = 0; (i) < (tot); ++(i))
    printf("%d% d% lld\n", px[i], py[i], ps[i]);
  return 0;
}