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>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 1005;
const ll mod = 1e9 + 7;
ll n, m, A, B, pref[N][N], a[N][N];
void gorizontal() {
  for (int i = 1; i <= n; i++) {
    deque<pair<int, int> > mn;
    for (int j = 1; j <= m; j++) {
      while (mn.size() && a[i][j] < mn.front().first) {
        mn.pop_front();
      }
      mn.push_front({a[i][j], j});
      while (mn.size() && j - mn.back().second + 1 > B) {
        mn.pop_back();
      }
      if (j >= B) a[i][j - B + 1] = mn.back().first;
    }
  }
  m = m - B + 1;
}
void vertical() {
  for (int j = 1; j <= m; j++) {
    deque<pair<int, int> > mn;
    for (int i = 1; i <= n; i++) {
      while (mn.size() && a[i][j] < mn.front().first) {
        mn.pop_front();
      }
      mn.push_front({a[i][j], i});
      while (mn.size() && i - mn.back().second + 1 > A) {
        mn.pop_back();
      }
      if (i >= A) a[i - A + 1][j] = mn.back().first;
    }
  }
  n = n - A + 1;
}
void calc() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      a[i][j] = -1 * A * B * a[i][j] + pref[i + A - 1][j + B - 1] +
                pref[i - 1][j - 1] - pref[i + A - 1][j - 1] -
                pref[i - 1][j + B - 1];
    }
  }
}
int t[N][4 * N], o[N][4 * N];
void push(int v, int l, int r, int line) {
  if (l != r) {
    t[line][v * 2] += o[line][v];
    t[line][v * 2 + 1] += o[line][v];
    o[line][v * 2] += o[line][v];
    o[line][v * 2 + 1] += o[line][v];
    o[line][v] = 0;
  }
}
void update(int v, int l, int r, int tl, int tr, int line) {
  if (tl > tr || l > r || r < tl || l > tr) return;
  if (tl == l && r == tr) {
    t[line][v]++;
    o[line][v]++;
    return;
  }
  push(v, l, r, line);
  int mid = (l + r) >> 1;
  update(v * 2, l, mid, tl, min(mid, tr), line);
  update(v * 2 + 1, mid + 1, r, max(mid + 1, tl), tr, line);
  t[line][v] = t[line][v * 2] + t[line][v * 2 + 1];
}
int get(int v, int l, int r, int pos, int line) {
  if (l > pos || r < pos || l > r) return 0;
  if (l == r && l == pos) return t[line][v];
  push(v, l, r, line);
  int mid = (l + r) >> 1;
  if (mid >= pos) return get(v * 2, l, mid, pos, line);
  return get(v * 2 + 1, mid + 1, r, pos, line);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> A >> B;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      pref[i][j] =
          a[i][j] + pref[i][j - 1] + pref[i - 1][j] - pref[i - 1][j - 1];
    }
  }
  gorizontal();
  vertical();
  calc();
  vector<pair<ll, pair<int, int> > > s;
  vector<pair<ll, pair<int, int> > > ans;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      s.push_back({a[i][j], {i, j}});
    }
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < n * m; i++) {
    if (get(1, 1, m, s[i].second.second, s[i].second.first)) continue;
    int tl = max(1ll, s[i].second.second - B + 1);
    int tr = min(m, s[i].second.second + B - 1);
    for (int j = max(1ll, s[i].second.first - A + 1);
         j <= min(n, s[i].second.first + A - 1); j++) {
      update(1, 1, m, tl, tr, j);
    }
    ans.push_back(s[i]);
  }
  cout << ans.size() << E;
  for (auto i : ans) {
    cout << i.second.first << " " << i.second.second << " " << i.first << E;
  }
  return 0;
}