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 JAVA):

Solution:
/**
 * Codeforces Beta Round 15
 * 
 * @author ProjectYoung
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class CF15D {
  private void solve(InputReader in, PrintWriter out) {
    int n = in.nextInt();
    int m = in.nextInt();
    int a = in.nextInt();
    int b = in.nextInt();
    int[][] map = new int[n + 1][m + 1];
    for (int i = 1; i <= n; i++) {
      String[] tmp = in.nextLine().split(" ");
      for (int j = 1; j <= m; j++) {
        map[i][j] = Integer.parseInt(tmp[j - 1]);
      }
    }
    long[][] sum = new long[n + 1][m + 1];
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + map[i][j];
      }
    }
    int[][] min = new int[m - b + 2][n + 1];
    for (int i = 1; i <= n; i++) {
      SegmentTree st = new SegmentTree(map[i]);
      for (int j = 1; j + b - 1 <= m; j++) {
        min[j][i] = st.query(j, j + b - 1);
      }
    }
    Cost[] list = new Cost[(n - a + 1) * (m - b + 1)];
    int len = 0;
    for (int j = 1; j + b - 1 <= m; j++) {
      SegmentTree st = new SegmentTree(min[j]);
      for (int i = 1; i + a - 1 <= n; i++) {
        long cost =
            sum[i + a - 1][j + b - 1] - sum[i + a - 1][j - 1] - sum[i - 1][j + b - 1]
                + sum[i - 1][j - 1] - (long) st.query(i, i + a - 1) * a * b;
        list[len++] = new Cost(cost, i, j);
      }
    }
    Arrays.sort(list, new Comparator<Cost>() {
      public int compare(Cost a, Cost b) {
        if (a.c < b.c || (a.c == b.c && a.x < b.x) || (a.c == b.c && a.x == b.x && a.y < b.y)) {
          return -1;
        } else if (a.c == b.c && a.x == b.x && a.y == b.y) {
          return 0;
        } else {
          return 1;
        }
      }
    });
    boolean[][] taken = new boolean[n + 1][m + 1];
    ArrayList<Cost> res = new ArrayList<>();
    for (int k = 0; k < list.length; k++) {
      Cost cur = list[k];
      if (taken[cur.x][cur.y]) {
        continue;
      }
      res.add(cur);
      for (int i = -a + 1; i < a; i++) {
        for (int j = -b + 1; j < b; j++) {
          if (cur.x + i < 1 || cur.x + i > n || cur.y + j < 1 || cur.y + j > m) {
            continue;
          }
          taken[cur.x + i][cur.y + j] = true;
        }
      }
    }
    out.println(res.size());
    for (Cost cost : res) {
      out.println(cost.x + " " + cost.y + " " + cost.c);
    }
  }

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new CF15D().solve(in, out);
    out.close();
  }

  static class Cost {
    long c;
    int x;
    int y;

    public Cost(long c, int x, int y) {
      this.c = c;
      this.x = x;
      this.y = y;
    }
  }

  static class SegmentTree {
    int n;
    int[] val;

    public SegmentTree(int n) {
      this.n = n;
      this.val = new int[2 * n - 1];
    }

    public SegmentTree(int[] num) {
      this.n = num.length;
      this.val = new int[2 * n - 1];
      for (int i = 2 * n - 2; i >= n - 1; i--) {
        val[i] = num[i - n + 1];
      }
      for (int i = n - 2; i >= 0; i--) {
        val[i] = Math.min(val[(i << 1) + 1], val[(i << 1) + 2]);
      }
    }

    public void update(int p, int v) {
      val[p + n - 1] = v;
      p = (p + n - 2) >> 1;
      while (p >= 0) {
        int min = Math.min(val[(p << 1) + 1], val[(p << 1) + 2]);
        if (val[p] == min) {
          return;
        }
        val[p] = min;
        p = (p - 1) >> 1;
      }
    }

    public int query(int l, int r) {
      int min = Integer.MAX_VALUE;
      for (l += n - 1, r += n - 1; l <= r; l = (l - 1) >> 1, r = (r - 1) >> 1) {
        min = ((l & 1) == 0 && min > val[l++]) ? val[l - 1] : min;
        min = ((r & 1) == 1 && min > val[r--]) ? val[r + 1] : min;
      }
      return min;
    }
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String nextLine() {
      if (tokenizer != null && tokenizer.hasMoreTokens()) {
        throw new RuntimeException();
      }
      try {
        String nextLine = reader.readLine();
        return nextLine;
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }
  }
}