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 static java.util.Arrays.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import java.util.*;
import java.math.*;
import java.io.*;

public class D implements Runnable
{
	String file = "input";
	
	void init() throws IOException
	{
		//input = new BufferedReader(new FileReader(file + ".in"));
		input = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new BufferedOutputStream(System.out));
	}
	
	int[] xs, ys;
	long[] cost;
	void solve() throws IOException
	{
		int rn = nextInt(), cn = nextInt(), a = nextInt(), b = nextInt();
		int[][] h = new int[rn][cn];
		for(int i = 0; i < rn; i++)
			for(int j = 0; j < cn; j++) h[i][j] = nextInt();
		long[][] sum = new long[rn][cn];
		for(int i = 0; i < rn; i++)
			for(int j = 0; j < cn; j++)
			{
				if(i > 0) sum[i][j] += sum[i - 1][j];
				if(j > 0) sum[i][j] += sum[i][j - 1];
				if(i > 0 && j > 0) sum[i][j] -= sum[i - 1][j - 1];
				sum[i][j] += h[i][j];
			}
		//print(slidingWindow(8, 3, new int[] {1, 3, -1, -3, 5, 3, 6, 7}));
		int[][] A = new int[cn][rn];
		int[] tmp = new int[rn];
		q = new int[rn];
		ind = new int[rn];
		for(int j = 0; j < cn; j++)
		{
			for(int i = 0; i < rn; i++) tmp[i] = h[i][j];
			slidingWindow(rn, a, tmp, A[j]);
		}
		int[] B = new int[cn];
		tmp = new int[cn];
		q = new int[cn];
		ind = new int[cn];
		xs = new int[rn * cn];
		ys = new int[rn * cn];
		cost = new long[rn * cn];
		int m = 0;
		for(int i = a - 1; i < rn; i++)
		{
			for(int j = 0; j < cn; j++) tmp[j] = A[j][i];
			slidingWindow(cn, b, tmp, B);
			for(int j = b - 1; j < cn; j++)
			{
				long S = sum[i][j];
				if(j - b >= 0) S -= sum[i][j - b];
				if(i - a >= 0) S -= sum[i - a][j];
				if(i - a >= 0 && j - b >= 0) S += sum[i - a][j - b];
				S -= (long)a * b * B[j];
				xs[m] = i - a + 1;
				ys[m] = j - b + 1;
				cost[m++] = S;
			}
		}
		Integer[] o = new Integer[m];
		for(int i = 0; i < m; i++) o[i] = i;
		sort(o, new Comparator<Integer>(){
			public int compare(Integer i, Integer j)
			{
				if(cost[i] < cost[j]) return -1;
				if(cost[i] > cost[j]) return 1;
				if(xs[i] != xs[j]) return xs[i] - xs[j];
				return ys[i] - ys[j];
			}
		});
		boolean[][] done = new boolean[rn][cn];
		int[] x = new int[m];
		int[] y = new int[m];
		long[] z = new long[m];
		int r = 0;
		for(int e = 0; e < m; e++)
		{
			int i = xs[o[e]], j = ys[o[e]];
			boolean ok = true;
			for(int k = j; k < j + b; k++)
			{ 
				ok &= !done[i][k] & !done[i + a - 1][k];
				if(!ok) break;
			}
			if(!ok) continue;
			for(int k = i; k < i + a; k++) 
			{
				ok &= !done[k][j] & !done[k][j + b - 1];
				if(!ok) break;
			}
			if(ok)
			{
				for(int ii = i; ii < i + a; ii++)
					for(int jj = j; jj < j + b; jj++) done[ii][jj] = true;
				x[r] = i;
				y[r] = j;
				z[r++] = cost[o[e]];
			} 
		}
		out.println(r);
		for(int i = 0; i < r; i++) out.println(++x[i] + " " + ++y[i] + " " + z[i]);		
	}	
	
	
	int INF = 1 << 30;
	int[] q, ind;
	void slidingWindow(int n, int k, int[] xs, int[] res)
	{
		q[0] = INF;
		int st = 0, en = 0;
		for(int i = 0; i < n; i++)
		{
			if(ind[st] < i - k + 1) st++;
			while(en >= st && q[en] >= xs[i]) en--;
			q[++en] = xs[i];
			ind[en] = i;
			res[i] = q[st];
		}
	}
	
	String next() throws IOException
	{
		while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(input.readLine());
		return st.nextToken();
	}
	
	int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}
	
	long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}
	
	double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}
	
	void print(Object... o)
	{
		System.out.println(deepToString(o));
	}
	
	void gcj(Object o)
	{
		String s = String.valueOf(o);
		out.println("Case #" + test + ": " + s);
		System.out.println("Case #" + test + ": " + s);
	}
	
	BufferedReader input;
	PrintWriter out;
	StringTokenizer st;
	int test;
	
	public static void main(String[] args) throws IOException
	{
		new Thread(null, new D(), "", 1 << 20).start();
	}
	
	public void run()
	{
		try
		{
			init();
			solve();
			out.close();		
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.exit(1);
		}
	}
}