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 Cell {
  int x;
  int y;
  long long m;
  bool operator<(const Cell &other) const {
    return ((m < other.m) ||
            (m == other.m && (x < other.x || (x == other.x && y < other.y))));
  }
};
const int N = 1024;
const int MAX = 1e9;
class SegTree2D {
 public:
  SegTree2D() {
    int i, j;
    for (i = 1; i < 2 * N; i++) {
      for (j = 1; j < 2 * N; j++) {
        a[i][j] = MAX;
      }
    }
  }
  void init(int array[][N], int n, int m) {
    int i, j;
    for (i = 2 * N - 1; i >= 1; i--) {
      for (j = 2 * N - 1; j >= 1; j--) {
        if (i >= N && j >= N) {
          if (i - N + 1 <= n && j - N + 1 <= m) {
            a[i][j] = array[i - N + 1][j - N + 1];
          }
        } else if (j < N) {
          a[i][j] = min(a[i][j + j], a[i][j + j + 1]);
        } else {
          a[i][j] = min(a[i + i][j], a[i + i + 1][j]);
        }
      }
    }
  }
  int query(int lx, int ly, int rx, int ry) {
    lx--;
    ly--;
    const int LY = ly + N, RY = ry + N;
    int ret = MAX;
    for (lx += N, rx += N; lx < rx; lx >>= 1, rx >>= 1) {
      if (lx & 1) {
        for (ly = LY, ry = RY; ly < ry; ly >>= 1, ry >>= 1) {
          if (ly & 1) {
            ret = min(ret, a[lx][ly]);
            ly++;
          }
          if (ry & 1) {
            ry--;
            ret = min(ret, a[lx][ry]);
          }
        }
        lx++;
      }
      if (rx & 1) {
        rx--;
        for (ly = LY, ry = RY; ly < ry; ly >>= 1, ry >>= 1) {
          if (ly & 1) {
            ret = min(ret, a[rx][ly]);
            ly++;
          }
          if (ry & 1) {
            ry--;
            ret = min(ret, a[rx][ry]);
          }
        }
      }
    }
    return ret;
  }
  void update(int x, int y, int val) {
    x--;
    y--;
    int X = x + N;
    int Y = y + N;
    a[x + N][y + N] = val;
    for (x = X; x > 1; x >>= 1) {
      for (y = Y; y > 1; y >>= 1) {
        a[x >> 1][y] = min(a[x][y], a[x ^ 1][y]);
        a[x][y >> 1] = min(a[x][y], a[x][y ^ 1]);
      }
      a[x >> 1][y] = min(a[x][y], a[x ^ 1][y]);
    }
  }

 private:
  int a[2 * N][2 * N];
};
int g[N][N];
long long sum[N][N];
long long row[N][2];
long long col[N][N];
vector<Cell> cellSet;
bool rm[N][N];
vector<Cell> ans;
SegTree2D st;
int main() {
  int n, m, a, b, i, j;
  Cell cell;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      scanf("%d", &g[i][j]);
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= b; j++) {
      row[i][1] += g[i][j];
    }
  }
  for (j = 1; j <= m; j++) {
    for (i = 1; i <= a; i++) {
      col[1][j] += g[i][j];
    }
    for (i = 2; i + a - 1 <= n; i++) {
      col[i][j] = col[i - 1][j] + g[i + a - 1][j] - g[i - 1][j];
    }
  }
  for (i = 1; i <= a; i++) {
    for (j = 1; j <= b; j++) {
      sum[1][1] += g[i][j];
    }
  }
  for (i = 1; i + a - 1 <= n; i++) {
    if (i != 1) {
      sum[i][1] = sum[i - 1][1] + row[i + a - 1][1] - row[i - 1][1];
    }
    for (j = 2; j + b - 1 <= m; j++) {
      sum[i][j] = sum[i][j - 1] + col[i][j + b - 1] - col[i][j - 1];
    }
  }
  st.init(g, n, m);
  long long minH;
  for (i = 1; i + a - 1 <= n; i++) {
    for (j = 1; j + b - 1 <= m; j++) {
      minH = st.query(i, j, i + a - 1, j + b - 1);
      sum[i][j] = sum[i][j] - (long long)a * b * minH;
      cell.x = i;
      cell.y = j;
      cell.m = sum[i][j];
      cellSet.push_back(cell);
    }
  }
  sort(cellSet.begin(), cellSet.end());
  int left, right, up, down;
  for (int k = 0; k < cellSet.size(); k++) {
    if (rm[cellSet[k].x][cellSet[k].y]) {
      continue;
    }
    ans.push_back(cellSet[k]);
    up = cellSet[k].x - a + 1;
    down = cellSet[k].x + a - 1;
    left = cellSet[k].y - b + 1;
    right = cellSet[k].y + b - 1;
    for (i = up; i <= down; i++) {
      for (j = left; j <= right; j++) {
        if (i < 1 || j < 1) {
          continue;
        }
        rm[i][j] = true;
      }
    }
  }
  printf("%d\n", ans.size());
  for (i = 0; i < ans.size(); i++) {
    printf(
        "%d %d "
        "%I64d"
        "\n",
        ans[i].x, ans[i].y, ans[i].m);
  }
  return 0;
}