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 a, b, n, m;
int t[1002][1002];
long long s[1002][1002];
int g[1002][1002];
long long r[1002][1002];
int f[1002][1002];
struct elem {
  int xm, m;
  long long s, xs;
  elem(int xm_, long long xs_, int m_, long long s_) {
    xm = xm_;
    xs = xs_;
    m = m_;
    s = s_;
  }
  elem(int xm_, long long xs_) {
    xm = m = xm_;
    xs = s = xs_;
  }
};
stack<elem> s1, s2;
void clear() {
  while (!s1.empty()) s1.pop();
  while (!s2.empty()) s2.pop();
}
void add(long long xs, int xm) {
  if (s1.empty())
    s1.push(elem(xm, xs));
  else {
    elem temp = s1.top();
    s1.push(elem(xm, xs, (xm < temp.m ? xm : temp.m), 1ll * xs + temp.s));
  }
}
void remove() {
  if (s2.empty()) {
    elem temp = s1.top(), temp2 = elem(temp.xm, temp.xs);
    s1.pop();
    s2.push(temp2);
    while (!s1.empty()) {
      temp = s1.top();
      s1.pop();
      temp2 = elem(temp.xm, temp.xs, (temp.xm < temp2.m ? temp.xm : temp2.m),
                   1ll * temp.xs + temp2.s);
      s2.push(temp2);
    }
  }
  s2.pop();
}
long long stsum() {
  return (s1.empty() ? 0 * 1ll : s1.top().s) +
         (s2.empty() ? 0 * 1ll : s2.top().s);
}
int stmin() {
  return ((s1.empty() ? (int)(1E9 + 1) : s1.top().m) <
                  (s2.empty() ? (int)(1E9 + 1) : s2.top().m)
              ? (s1.empty() ? (int)(1E9 + 1) : s1.top().m)
              : (s2.empty() ? (int)(1E9 + 1) : s2.top().m));
}
bool cmp(pair<int, int> i, pair<int, int> j) {
  if (r[i.first][i.second] < r[j.first][j.second]) return true;
  if (r[i.first][i.second] > r[j.first][j.second]) return false;
  if (i.first < j.first) return true;
  if (i.first > j.first) return false;
  if (i.second < j.second) return true;
  if (i.second > j.second) return false;
}
void init() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) f[i][j] = 0;
}
void inc(int i, int j) {
  int r;
  for (; i < n; i = (i | (i + 1)))
    for (r = j; r < m; r = (r | (r + 1))) f[i][r]++;
}
int sum(int i, int j) {
  int res = 0, r;
  for (; i >= 0; i = (i & (i + 1)) - 1)
    for (r = j; r >= 0; r = (r & (r + 1)) - 1) res += f[i][r];
  return res;
}
void fadd(int i, int j) {
  for (int k = i; k < i + a; k++)
    for (int t = j; t < j + b; t++) inc(k, t);
}
bool ok(int i, int j) {
  return (sum(i + a - 1, j + b - 1) - sum(i + a - 1, j - 1) -
          sum(i - 1, j + b - 1) + sum(i - 1, j - 1)) == 0;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &a, &b);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &t[i][j]);
  for (int i = 0; i < n; i++) {
    clear();
    for (int j = 0; j < b; j++) add(t[i][j], t[i][j]);
    for (int j = 0; j <= m - b; j++) {
      s[i][j] = stsum();
      g[i][j] = stmin();
      remove();
      add(t[i][j + b], t[i][j + b]);
    }
  }
  for (int j = 0; j <= m - b; j++) {
    clear();
    for (int i = 0; i < a; i++) add(s[i][j], g[i][j]);
    for (int i = 0; i <= n - a; i++) {
      s[i][j] = stsum();
      g[i][j] = stmin();
      remove();
      add(s[i + a][j], g[i + a][j]);
    }
  }
  int k = a * b;
  for (int i = 0; i <= n - a; i++)
    for (int j = 0; j <= m - b; j++) r[i][j] = s[i][j] - k * 1ll * g[i][j];
  vector<pair<int, int> > res((n - a + 1) * (m - b + 1));
  k = 0;
  for (int i = 0; i <= n - a; i++)
    for (int j = 0; j <= m - b; j++) res[k] = make_pair(i, j), k++;
  sort(res.begin(), res.end(), cmp);
  init();
  vector<pair<int, int> > print;
  for (k = 0; k < res.size(); k++) {
    int i = res[k].first, j = res[k].second;
    if (ok(i, j)) {
      print.push_back(res[k]);
      fadd(i, j);
    }
  }
  printf("%d\n", print.size());
  for (int i = 0; i < print.size(); i++)
    printf("%d %d %I64d\n", print[i].first + 1, print[i].second + 1,
           r[print[i].first][print[i].second]);
  return 0;
}