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;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * f;
}
const int MAX_N = 1e3 + 10;
int H[MAX_N][MAX_N], CM[MAX_N][MAX_N], TM[MAX_N][MAX_N], N, M, A, B, SUM = 0;
long long S[MAX_N][MAX_N];
bool vis[MAX_N][MAX_N];
vector<pair<long long, pair<int, int> > > V, Ans;
struct MY_QUEUE {
  deque<pair<int, int> > Q;
  inline void reset() { Q.clear(); }
  inline void push(int val, int mark) {
    pair<int, int> now = make_pair(val, mark);
    while (Q.size() && Q.back().first > val) Q.pop_back();
    Q.push_back(make_pair(val, mark));
  }
  inline void pop(int mark) {
    if (Q.front().second == mark) Q.pop_front();
  }
  inline int get() { return Q.front().first; }
};
inline bool check_X(int x) { return x >= 0 && x < N; }
inline bool check_Y(int y) { return y >= 0 && y < M; }
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  N = read();
  M = read();
  A = read();
  B = read();
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) H[i][j] = read();
  for (int i = 0; i < M; i++) {
    MY_QUEUE QUEUE;
    for (int j = 0; j < N; j++) {
      QUEUE.push(H[j][i], j);
      if (j >= A) QUEUE.pop(j - A);
      if (j >= A - 1) CM[j - A + 1][i] = QUEUE.get();
    }
  }
  for (int i = 0; i < N; i++) {
    MY_QUEUE QUEUE;
    for (int j = 0; j < M; j++) {
      QUEUE.push(CM[i][j], j);
      if (j >= B) QUEUE.pop(j - B);
      if (j >= B - 1) TM[i][j - B + 1] = QUEUE.get();
    }
  }
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++)
      S[i][j] = (long long)S[i][j] + S[i][j - 1] + H[i - 1][j - 1];
  for (int i = 1; i <= M; i++)
    for (int j = 1; j <= N; j++) S[j][i] = (long long)S[j][i] + S[j - 1][i];
  for (int i = 0; i <= N - A; i++)
    for (int j = 0; j <= M - B; j++) {
      long long sum = (long long)S[i + A][j + B] - S[i + A][j] - S[i][j + B] +
                      S[i][j],
                dec = (long long)TM[i][j] * A * B;
      V.push_back(make_pair(sum - dec, make_pair(i, j)));
    }
  sort(V.begin(), V.end());
  for (int i = 0; i < V.size(); i++) {
    long long val = V[i].first;
    int X = V[i].second.first, Y = V[i].second.second;
    if (vis[X][Y]) continue;
    SUM++;
    Ans.push_back(make_pair(val, make_pair(X + 1, Y + 1)));
    for (int i = X - A + 1; i <= X + A - 1; i++)
      for (int j = Y - B + 1; j <= Y + B - 1; j++)
        if (check_X(i) && check_Y(j)) vis[i][j] = 1;
  }
  printf("%d\n", SUM);
  for (int i = 0; i < Ans.size(); i++)
    printf("%d %d %I64d\n", Ans[i].second.first, Ans[i].second.second,
           Ans[i].first);
  return 0;
}