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;
template <class T, int MAX_N>
void BIT2D_Add(T tree[][MAX_N], int m, int n, int idx, int idy, T value) {
  for (int x = idx + 1; x <= m; x += x & -x)
    for (int y = idy + 1; y <= n; y += y & -y) tree[x][y] += value;
}
template <class T, int MAX_N>
T BIT2D_Read(const T tree[][MAX_N], int m, int n, int idx, int idy) {
  T sum = 0;
  for (int x = idx; x > 0; x &= x - 1)
    for (int y = idy; y > 0; y &= y - 1) sum += tree[x][y];
  return sum;
}
const int MAX_LOG_N = 10, MAX_N = 1 << MAX_LOG_N;
int logTable[MAX_N + 1];
void PreprocessLogTable() {
  logTable[1] = 0;
  for (int d = 2; d <= MAX_N; ++d) logTable[d] = logTable[d >> 1] + 1;
}
template <class T, class MergeFunctor>
int PreprocessRMQ2D(T rmq[][MAX_N][MAX_N], int rows, int m, int n, int a, int b,
                    MergeFunctor functor) {
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j) rmq[0][i][j] = functor.get(i, j);
  for (int kb = 1; kb <= b; ++kb) {
    const int me = kb % rows, old = (kb - 1) % rows;
    for (int i = 0; i < m; ++i)
      for (int j = 0; j + (1 << kb) <= n; ++j)
        rmq[me][i][j] =
            functor(rmq[old][i][j], rmq[old][i][j + (1 << (kb - 1))]);
  }
  const int nb = n - (1 << b);
  if (b % rows != 0)
    for (int i = 0; i < m; ++i)
      for (int j = 0; j <= nb; ++j) rmq[0][i][j] = rmq[b % rows][i][j];
  for (int ka = 1; ka <= a; ++ka) {
    const int me = ka % rows, old = (ka - 1) % rows;
    for (int i = 0; i + (1 << ka) <= m; ++i)
      for (int j = 0; j <= nb; ++j)
        rmq[me][i][j] =
            functor(rmq[old][i][j], rmq[old][i + (1 << (ka - 1))][j]);
  }
  return a % rows;
}
template <class T, class MergeFunctor>
T QueryRMQ2D(const T rmq[MAX_N][MAX_N], int i1, int j1, int i2, int j2,
             MergeFunctor functor) {
  const int ka = logTable[i2 - i1], kb = logTable[j2 - j1];
  return functor(functor(rmq[i1][j1], rmq[i2 - (1 << ka)][j2 - (1 << kb)]),
                 functor(rmq[i1][j2 - (1 << kb)], rmq[i2 - (1 << ka)][j1]));
}
template <class T, int MAX_N>
struct RMQ_MinFunctor {
  RMQ_MinFunctor(const T v_[MAX_N][MAX_N]) : v(v_) {}
  const T& get(int a, int b) const { return v[a][b]; }
  T operator()(int a, int b) const { return min(a, b); }
  const T (*const v)[MAX_N];
};
struct state_t {
  state_t(int i_, int j_, long long cost_) : i(i_), j(j_), cost(cost_) {}
  bool operator<(const state_t& rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (i != rhs.i) return i < rhs.i;
    if (j != rhs.j) return j < rhs.j;
    return false;
  }
  int i, j;
  long long cost;
};
const int RMQ_ROWS = 2;
int grid[MAX_N][MAX_N], m, n;
long long tree[MAX_N][MAX_N];
int cnt[MAX_N][MAX_N];
int rmq[RMQ_ROWS][MAX_N][MAX_N];
template <class T>
T QueryRange(const T tree[MAX_N][MAX_N], int i1, int j1, int i2, int j2) {
  return BIT2D_Read(tree, m, n, i2, j2) - BIT2D_Read(tree, m, n, i1, j2) -
         BIT2D_Read(tree, m, n, i2, j1) + BIT2D_Read(tree, m, n, i1, j1);
}
long long GetCost(int rmqRow, int i1, int j1, int i2, int j2) {
  const long long total = QueryRange(tree, i1, j1, i2, j2);
  const int level =
      QueryRMQ2D(rmq[rmqRow], i1, j1, i2, j2, RMQ_MinFunctor<int, MAX_N>(grid));
  return total - level * (long long)(i2 - i1) * (long long)(j2 - j1);
}
int main() {
  PreprocessLogTable();
  int a, b;
  scanf("%d %d %d %d", &m, &n, &a, &b);
  memset(tree, 0, sizeof(tree));
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j) {
      scanf("%d", &grid[i][j]);
      BIT2D_Add(tree, m, n, i, j, (long long)grid[i][j]);
      BIT2D_Add(cnt, m, n, i, j, 1);
    }
  const int rmqRow =
      PreprocessRMQ2D(rmq, RMQ_ROWS, m, n, logTable[a], logTable[b],
                      RMQ_MinFunctor<int, MAX_N>(grid));
  vector<state_t> cities;
  for (int i = 0; i + a <= m; ++i)
    for (int j = 0; j + b <= n; ++j)
      cities.push_back(state_t(i, j, GetCost(rmqRow, i, j, i + a, j + b)));
  sort(cities.begin(), cities.end());
  vector<state_t> constructed;
  for (int k = 0; k < (int)cities.size(); ++k) {
    const int i = cities[k].i, j = cities[k].j;
    if (QueryRange(cnt, i, j, i + a, j + b) == a * b) {
      constructed.push_back(cities[k]);
      for (int ii = i; ii < i + a; ++ii)
        for (int jj = j; jj < j + b; ++jj) BIT2D_Add(cnt, m, n, ii, jj, -1);
    }
  }
  printf("%d\n", (int)constructed.size());
  for (int k = 0; k < (int)constructed.size(); ++k)
    printf("%d %d %I64d\n", constructed[k].i + 1, constructed[k].j + 1,
           constructed[k].cost);
  return 0;
}