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 INF = (int)2e9;
const long long INFL = (long long)9e18;
const int MAXINT = ((~0) ^ (1 << 31));
const long long MAXLL = ((~0) ^ ((long long)1 << 63));
template <class T>
inline T pow2(T a) {
  return a * a;
}
template <class T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, true) : false;
}
template <class T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, true) : false;
}
bool debug = 0;
const int maxn = (int)1111;
;
long long grid[maxn][maxn], mxrow[maxn][maxn], mx[maxn][maxn], sum[maxn][maxn];
bool visited[maxn][maxn];
struct city {
  long long x, y, mx;
  city(long long _x, long long _y, long long _mx) {
    x = _x;
    y = _y;
    mx = _mx;
  }
  bool operator<(const city& a) const {
    if (mx != a.mx) return mx < a.mx;
    if (x != a.x) return x < a.x;
    return y < a.y;
  }
};
vector<city> num;
long long n, m, a, b;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &a, &b);
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(m); j++) {
      scanf("%I64d", grid[i] + j);
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    deque<int> dq;
    for (int j = m - 1; j >= (int)(0); j--) {
      while (!dq.empty() && grid[i][dq.front()] >= grid[i][j]) dq.pop_front();
      dq.push_front(j);
      while (dq.back() >= j + b) dq.pop_back();
      mxrow[i][j] = grid[i][dq.back()];
    }
  }
  if (debug) {
    cout << "mx row: " << endl;
    for (int i = 0; i < (int)(n); i++) {
      for (int j = 0; j < (int)(m); j++) {
        cout << mxrow[i][j] << " ";
      }
      cout << endl;
    }
  }
  for (int j = 0; j < (int)(m); j++) {
    deque<int> dq;
    for (int i = n - 1; i >= (int)(0); i--) {
      while (!dq.empty() && mxrow[dq.front()][j] >= mxrow[i][j]) dq.pop_front();
      dq.push_front(i);
      while (dq.back() >= i + a) dq.pop_back();
      mx[i][j] = mxrow[dq.back()][j];
    }
  }
  if (debug) {
    cout << "mx: " << endl;
    for (int i = 0; i < (int)(n); i++) {
      for (int j = 0; j < (int)(m); j++) {
        cout << mx[i][j] << " ";
      }
      cout << endl;
    }
  }
  for (int i = n - 1; i >= (int)(0); i--) {
    for (int j = m - 1; j >= (int)(0); j--) {
      sum[i][j] =
          grid[i][j] + sum[i + 1][j] + sum[i][j + 1] - sum[i + 1][j + 1];
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(m); j++) {
      if (i + a <= n && j + b <= m) {
        long long minus =
            sum[i][j] - sum[i + a][j] - sum[i][j + b] + sum[i + a][j + b];
        num.push_back(city(i, j, minus - mx[i][j] * a * b));
      }
    }
  }
  sort(num.begin(), num.end());
  vector<pair<pair<long long, long long>, long long> > ans;
  for (int id = 0; id < (int)(num.size()); id++) {
    int x = num[id].x;
    int y = num[id].y;
    if (visited[x][y]) continue;
    ans.push_back(make_pair(make_pair(x, y), num[id].mx));
    for (int i = max(0ll, x - a + 1); i < (int)(min(n, x + a)); i++) {
      for (int j = max(0ll, y - b + 1); j < (int)(min(m, y + b)); j++) {
        if (debug) cout << "mp: " << i << " " << j << endl;
        visited[i][j] = true;
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < (int)(ans.size()); i++) {
    printf("%I64d %I64d %I64d\n", ans[i].first.first + 1,
           ans[i].first.second + 1, ans[i].second);
  }
}