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 maxn = 1002;
const int INF = 1000 * 1000 * 1000 + 97;
struct Rect {
  int x, y;
  long long musor;
  Rect(int xx, int yy, long long mus) {
    x = xx;
    y = yy;
    musor = mus;
  }
  friend inline bool operator<(const Rect& a, const Rect& b) {
    if (a.musor != b.musor) return a.musor < b.musor;
    if (a.y != b.y) return a.y < b.y;
    return a.x < b.x;
  }
};
int n, m, a, b;
struct RMQ {
  int count;
  int shift;
  vector<int> mins;
  RMQ() { construct(maxn); }
  RMQ(int c) { construct(c); }
  void construct(int c) {
    count = c;
    shift = 1;
    while (shift < c) shift *= 2;
    mins.assign(2 * shift + 1, INF);
  }
  void setValue(int index, int value) {
    index += shift;
    mins[index] = value;
    while (index > 1)
      index /= 2, mins[index] = min(mins[2 * index], mins[2 * index + 1]);
  }
  int getMin(int l, int r) {
    l += shift;
    r += shift;
    int minimum = INF;
    while (l < r) {
      minimum = min(minimum, min(mins[l], mins[r - 1]));
      l = (l + 1) / 2;
      r /= 2;
    }
    return minimum;
  }
};
int hs[maxn][maxn];
long long ss[maxn][maxn];
RMQ fieldMins[maxn];
bool used[maxn][maxn];
vector<Rect> rs;
vector<Rect> answer;
int main() {
  cin >> n >> m >> a >> b;
  for (int yy = 0; yy < n; yy++)
    for (int xx = 0; xx < m; xx++) {
      scanf("%d", &hs[yy][xx]);
      ss[yy + 1][xx + 1] =
          hs[yy][xx] + ss[yy + 1][xx] + ss[yy][xx + 1] - ss[yy][xx];
    }
  for (int xx = 0; xx < m; xx++) {
    RMQ tempRmq(n);
    for (int yy = 0; yy < n; yy++) tempRmq.setValue(yy, hs[yy][xx]);
    for (int yy = 0; yy + a <= n; yy++)
      fieldMins[yy].setValue(xx, tempRmq.getMin(yy, yy + a));
  }
  rs.reserve((n - a + 1) * (m - b + 1));
  for (int yy = 0; yy <= n - a; yy++)
    for (int xx = 0; xx <= m - b; xx++) {
      long long baseMusor =
          ss[yy + a][xx + b] - ss[yy + a][xx] - ss[yy][xx + b] + ss[yy][xx];
      baseMusor -=
          fieldMins[yy].getMin(xx, xx + b) * (long long)a * (long long)b;
      rs.push_back(Rect(xx, yy, baseMusor));
    }
  sort(rs.begin(), rs.end());
  int maxAnswerCount = (n / a + 1) * (m / b + 1);
  answer.reserve(maxAnswerCount);
  for (int i = 0; i < rs.size(); i++) {
    Rect r = rs[i];
    if (used[r.y][r.x] || used[r.y + a - 1][r.x] || used[r.y][r.x + b - 1] ||
        used[r.y + a - 1][r.x + b - 1])
      continue;
    for (int yy = r.y; yy < r.y + a; yy++)
      for (int xx = r.x; xx < r.x + b; xx++) used[yy][xx] = true;
    answer.push_back(r);
    if (answer.size() >= maxAnswerCount) break;
  }
  cout << answer.size() << endl;
  for (int i = 0; i < answer.size(); i++)
    printf("%d %d %lld\n", answer[i].y + 1, answer[i].x + 1, answer[i].musor);
  return 0;
}