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.*;
import java.util.*;
 

public class Main {
	
	static class LIPair implements Comparable<LIPair>{ //Only use long to sort, ints not affected. Don't need array.
		long a;
		int y, z;
			
		LIPair(long a, int y, int z){
			this.a = a;
			this.y = y;
			this.z = z;
		}
		
		@Override public int compareTo(LIPair l){
			if(this.a < l.a){
				return -1;
			}
			if(this.a == l.a){
				return 0;
			}
			return 1;
		}
	}
	
	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader kek = new BufferedReader(new InputStreamReader(System.in));
		//Scanner skek = new Scanner(System.in);
		PrintWriter outkek = new PrintWriter(System.out);
		
		ArrayList<LIPair> arr = new ArrayList<>();
		ArrayList<LIPair> res = new ArrayList<>();
		
		char[][] track = new char[1001][1001];
		long[][] sum1 = new long[1001][1001], sum2 = new long[1001][1001], grid = new long[1001][1001];
		int[] index = new int[1001];
		
		String[] input = kek.readLine().split(" ");
		int N = Integer.parseInt(input[0]), M = Integer.parseInt(input[1]), A = Integer.parseInt(input[2]), B = Integer.parseInt(input[3]);
		
		int L = 0, R = 0;
		
		for(int i = 1; i <= N; i++){
			String[] input2 = kek.readLine().split(" ");
			for(int j = 1; j <= M; j++){
				grid[i][j] = Integer.parseInt(input2[j - 1]);
			}
		}
		
		for(int i = 1; i <= N; i++){
			L = 0;
			R = 0;
			for(int j = 1; j <= M; j++){
				while(L != R && index[L] < j - B + 1){
					L++;
				}
				while(L < R && grid[i][index[R-1]] >= grid[i][j]){
					R--;
				}
				
				index[R++] = j;
				if(j >= B){
					sum1[i][j - B + 1] = grid[i][index[L]];
				}
			}
		}
		
		for(int j = 1; j <= M; j++){
			L = 0;
			R = 0;
			for(int i = 1; i <= N; i++){
				while(L != R && index[L] < i - A + 1) {
					L++;
				}
				while(L < R && sum1[index[R - 1]][j] >= sum1[i][j]){
					R--;
				}
				index[R++] = i;
				if(i >= A){
					sum2[i - A + 1][j] = sum1[index[L]][j];
				}
			}
		}
		
		for(int i = 1; i <= N; i++){
			for(int j = 1; j <= M; j++){
				sum1[i][j] = sum1[i - 1][j] + sum1[i][j - 1] - sum1[i - 1][j - 1] + grid[i][j];
			}
		}
		
		for(int i = 1; i <= N - A + 1; i++){
			for(int j = 1; j <= M - B + 1; j++){
				grid[i][j] = sum1[i + A - 1][j + B - 1] - sum1[i - 1][j + B - 1] - sum1[i + A - 1][j - 1] + sum1[i - 1][j - 1] - sum2[i][j] * A * B;
				//pairInt p = new pairInt(i,j);
				//LIPair l = new LIPair(grid[i][j], p);
				LIPair l = new LIPair(grid[i][j], i, j);
				arr.add(l);
			}
		}
		
		Collections.sort(arr);
		
		for(int i = 0; i < arr.size(); i++){
			if(track[arr.get(i).y][arr.get(i).z] == 0){
				int mm1 = Math.max(1, arr.get(i).y - A + 1);
				int mmin1 = Math.min(N + 1, arr.get(i).y + A);
				int mm2 = Math.max(1, arr.get(i).z - B + 1);
				int mmin2 = Math.min(M + 1, arr.get(i).z + B);
				for(int j = mm1; j < mmin1; j++){
					for(int k = mm2; k < mmin2; k++){
						track[j][k] = 1;
					}
				}
				res.add(arr.get(i));
			}
		}
		
		outkek.println(res.size());
		for(LIPair l : res){
			outkek.println(l.y + " " + l.z + " " + l.a);
		}

		kek.close();
		outkek.close();
	}	
	
}