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:

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws FileNotFoundException, IOException {
		InputReader in = new InputReader(new BufferedInputStream(System.in));
		PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
		TaskB solver = new TaskB();
//		long t1 = System.currentTimeMillis();
		solver.solve(1, in, out);
		out.flush();
//		long t2 = System.currentTimeMillis();
//		System.err.println(t2 - t1);
		out.close();

	}
}

class Pos implements Comparable<Pos> {
	int x;
	int y;
	long val;

	public Pos(int x, int y, long val) {
		this.x = x;
		this.y = y;
		this.val = val;
	}

	public int compareTo(Pos p) {
		if (val == p.val) {
			if (x == p.x)
				return Integer.compare(y, p.y);
			return Integer.compare(x, p.x);
		}
		return Long.compare(val, p.val);
	}

}

class MinQueue {
	long[] a;
	int[] inds;
	int s, t;

	MinQueue(int n) {
		a = new long[n];
		inds = new int[n];
	}

	long min() {
		if (s == t) {
			throw new AssertionError();
		}
		return a[s];
	}

	void push(int i, long val) {
		while (s < t && a[t - 1] >= val) {
			--t;
		}
		a[t] = val;
		inds[t] = i;
		++t;
	}

	void pop(int i) {
		if (inds[s] == i) {
			++s;
		}
	}
}

class TaskB {

	int INF = (int) 1e9;

	void solve(int testNumber, InputReader in, PrintWriter pw) throws IOException {
		int n = in.nextInt();
		int m = in.nextInt();
		int u = in.nextInt();
		int v = in.nextInt();
		long[][] a = new long[n][m];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				a[i][j] = in.nextInt();
			}
		}
		long[][] mins = new long[n - u + 1][m];
		for (int j = 0; j < m; ++j) {
			MinQueue q = new MinQueue(n);
			for (int i = 0; i < u - 1; ++i) {
				q.push(i, a[i][j]);
			}
			for (int i = u - 1; i < n; ++i) {
				q.push(i, a[i][j]);
				mins[i - u + 1][j] = q.min();
				q.pop(i - u + 1);
			}
		}
		for (int i = 0; i < n - u + 1; ++i) {
			long[] tmp = new long[m - v + 1];
			MinQueue q = new MinQueue(m);
			for (int j = 0; j < v - 1; ++j) {
				q.push(j, mins[i][j]);
			}
			for (int j = v - 1; j < m; ++j) {
				q.push(j, mins[i][j]);
				tmp[j - v + 1] = q.min();
				q.pop(j - v + 1);
			}
			mins[i] = tmp;
		}
		long[][] sums = new long[n - u + 1][m];
		for (int j = 0; j < m; ++j) {
			long q = 0;
			for (int i = 0; i < u - 1; ++i) {
				q += a[i][j];
			}
			for (int i = u - 1; i < n; ++i) {
				q += a[i][j];
				sums[i - u + 1][j] = q;
				q -= a[i - u + 1][j];
			}
		}
		for (int i = 0; i < n - u + 1; ++i) {
			long[] tmp = new long[m - v + 1];
			long q = 0;
			for (int j = 0; j < v - 1; ++j) {
				q += sums[i][j];
			}
			for (int j = v - 1; j < m; ++j) {
				q += sums[i][j];
				tmp[j - v + 1] = q;
				q -= sums[i][j - v + 1];
			}
			sums[i] = tmp;
		}
		ArrayList<Pos> ps = new ArrayList<Pos>();
		for (int i = 0; i < n - u + 1; ++i) {
			for (int j = 0; j < m - v + 1; ++j) {
				ps.add(new Pos(i, j, sums[i][j] - mins[i][j] * u * v));
			}
		}
		Collections.sort(ps);
		boolean[][] bad = new boolean[n - u + 1][m - v + 1];
		ArrayList<Pos> ans = new ArrayList<Pos>();
		for (Pos p : ps) {
			if (!bad[p.x][p.y]) {
				ans.add(p);
				for (int i = -u + 1; i < u; ++i) {
					for (int j = -v + 1; j < v; ++j) {
						if (p.x + i >= 0 && p.x + i < n - u + 1 && p.y + j >= 0 && p.y + j < m - v + 1) {
							bad[p.x + i][p.y + j] = true;
						}
					}
				}
			}
		}
		pw.println(ans.size());
		for (Pos p : ans) {
			pw.println((p.x + 1) + " " + (p.y + 1) + " " + p.val);
		}
	}

	long gcd(long x, long y) {
		if (y == 0)
			return x;
		return gcd(y, x % y);
	}

	long pow(int n, int m) {
		if (m == 0)
			return 1;
		long ans = pow(n, m / 2);
		ans = (ans * ans);
		if (m % 2 == 1) {
			ans = (ans * n);
		}
		return ans;
	}

	double pow(double n, int m) {
		if (m == 0)
			return 1;
		double ans = pow(n, m / 2);
		ans = (ans * ans);
		if (m % 2 == 1) {
			ans = (ans * n);
		}
		return ans;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

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

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}