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;
#pragma comment(linker, "/STACK:200000000")
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
int h[1100][1100], mi[1100][1100], f[1100][1100];
long long sum[1100][1100], sum2[1100][1100];
bool pres[1100];
deque<pair<int, int> > st;
void add(int val, int id) {
  while (!st.empty() && st.back().first >= val) {
    pres[st.back().second] = false;
    st.pop_back();
  }
  st.push_back(make_pair(val, id));
  pres[id] = true;
}
void del(int val, int id) {
  if (!pres[id]) return;
  pres[id] = false;
  st.pop_front();
}
int n, m;
int f_sum(int x, int y) {
  int res = 0;
  for (int i = x; i >= 0; i = (i & (i + 1)) - 1)
    for (int j = y; j >= 0; j = (j & (j + 1)) - 1) res += f[i][j];
  return res;
}
void f_add(int x, int y) {
  for (int i = x; i < n; i = (i | (i + 1)))
    for (int j = y; j < m; j = (j | (j + 1))) f[i][j]++;
}
int f_sum(int x1, int y1, int x2, int y2) {
  int res = f_sum(x2, y2);
  if (x1) res -= f_sum(x1 - 1, y2);
  if (y1) res -= f_sum(x2, y1 - 1);
  if (x1 && y1) res += f_sum(x1 - 1, y1 - 1);
  return res;
}
int main() {
  int a, b;
  scanf("%d%d%d%d", &n, &m, &a, &b);
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(m); j++) scanf("%I64d", &h[i][j]);
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(m); j++) {
      sum2[i][j] = h[i][j];
      if (i) sum2[i][j] += sum2[i - 1][j];
      if (j) sum2[i][j] += sum2[i][j - 1];
      if (i && j) sum2[i][j] -= sum2[i - 1][j - 1];
    }
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(m); j++) {
      sum[i][j] = sum2[i][j];
      if (i - a >= 0) sum[i][j] -= sum2[i - a][j];
      if (j - b >= 0) sum[i][j] -= sum2[i][j - b];
      if (i - a >= 0 && j - b >= 0) sum[i][j] += sum2[i - a][j - b];
    }
  for (int y = 0; y < (int)(m); y++) {
    memset(pres, 0, sizeof(pres));
    st.clear();
    for (int x = 0; x < (int)(a); x++) add(h[x][y], x);
    mi[a - 1][y] = st[0].first;
    for (int x = (int)(a); x < (int)(n); x++) {
      add(h[x][y], x);
      del(h[x - a][y], x - a);
      mi[x][y] = st[0].first;
    }
  }
  vector<pair<long long, pair<int, int> > > ev;
  ev.reserve(n * m);
  for (int x = (int)(a - 1); x < (int)(n); x++) {
    memset(pres, 0, sizeof(pres));
    st.clear();
    for (int i = 0; i < (int)(b); i++) add(mi[x][i], i);
    ev.push_back(make_pair(sum[x][b - 1] - st[0].first * 1LL * a * 1LL * b,
                           make_pair(x, b - 1)));
    for (int y = (int)(b); y < (int)(m); y++) {
      add(mi[x][y], y);
      del(mi[x][y - b], y - b);
      ev.push_back(make_pair(sum[x][y] - st[0].first * 1LL * a * 1LL * b,
                             make_pair(x, y)));
    }
  }
  sort(ev.begin(), ev.end());
  vector<pair<pair<int, int>, long long> > e;
  for (int i = 0; i < (int)(ev.size()); i++) {
    int x = ev[i].second.first;
    int y = ev[i].second.second;
    int ss = f_sum(x - a + 1, y - b + 1, x, y);
    if (ss) continue;
    e.push_back(
        make_pair(make_pair(x - a + 1 + 1, y - b + 1 + 1), ev[i].first));
    f_add(x - a + 1, y - b + 1);
    f_add(x - a + 1, y);
    f_add(x, y - b + 1);
    f_add(x, y);
  }
  printf("%d\n", e.size());
  for (int i = 0; i < (int)(e.size()); i++)
    printf("%d %d %I64d\n", e[i].first.first, e[i].first.second, e[i].second);
  return 0;
}