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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rustam Musin (PloadyFree@gmail.com)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        int n;
        int m;
        int a;
        int b;
        int[][] h = new int[1000][1000];
        long[][] sum = new long[1000][1000];
        int[][] min = new int[1000][1000];
        boolean[][] used = new boolean[1000][1000];
        Data[] order = new Data[1000 * 1000];
        int orderSize;
        int[] inArray = new int[1000];
        int[] outArray = new int[1000];
        int[] inMins = new int[1000];
        int[] outMins = new int[1000];
        int inSize;
        int outSize;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            if (false) {
                test();
                return;
            }
            n = in.readInt();
            m = in.readInt();
            a = in.readInt();
            b = in.readInt();
            h = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    h[i][j] = in.readInt();
                }
            }

            solve();
            out.printLine(orderSize);
            for (int i = 0; i < orderSize; i++) {
                Data d = order[i];
                out.printLine(d.x + 1, d.y + 1, d.priority);
            }
        }

        void test() {
            n = 1000;
            m = 1000;
            a = 5;
            b = 5;
            solve();
        }

        void solve() {
            int n1 = n - a + 1;
            int m1 = m - b + 1;

            for (int i = 0; i < n; i++, inSize = outSize = 0) {
                long s = 0;
                for (int j = 0; j < m; j++) {
                    int x = h[i][j];
                    push(x);
                    s += x;
                    if (j + 1 >= b) {
                        sum[i][j - b + 1] = s;
                        min[i][j - b + 1] = min();
                        s -= pop();
                    }
                }
            }

            orderSize = 0;
            for (int j = 0; j < m1; j++, inSize = outSize = 0) {
                long s = 0;
                for (int i = 0; i < n; i++) {
                    push(min[i][j]);
                    s += sum[i][j];
                    if (i + 1 >= a) {
                        long priority = s - (a * (long) b * min());
                        order[orderSize++] = new Data(i - a + 1, j, priority);
                        s -= sum[i - a + 1][j];
                        pop();
                    }
                }
            }
            Arrays.sort(order, 0, orderSize);

            orderSize = 0;
            for (int iter = 0; iter < n1 * m1; iter++) {
                Data data = order[iter];
                int x = data.x;
                int y = data.y;
                int x1 = Math.min(n1 - 1, x + a - 1);
                int y1 = Math.min(m1 - 1, y + b - 1);
                if (used[x][y] || used[x][y1] || used[x1][y] || used[x1][y1]) {
                    continue;
                }
                for (int i = x; i <= x1; i++) {
                    for (int j = y; j <= y1; j++) {
                        used[i][j] = true;
                    }
                }
                order[orderSize++] = data;
            }
        }

        void push(int x) {
            inArray[inSize] = x;
            inMins[inSize] = Math.min(inSize == 0 ? x : inMins[inSize - 1], x);
            inSize++;
        }

        int pop() {
            if (outSize == 0) {
                while (inSize > 0) {
                    int x = inArray[--inSize];
                    outArray[outSize] = x;
                    outMins[outSize] = Math.min(outSize == 0 ? x : outMins[outSize - 1], x);
                    outSize++;
                }
            }
            return outArray[--outSize];
        }

        int min() {
            return Math
                    .min(inSize == 0 ? (int) 1e9 : inMins[inSize - 1], outSize == 0 ? (int) 1e9 : outMins[outSize - 1]);
        }

        class Data implements Comparable<Data> {
            int x;
            int y;
            long priority;

            public Data(int x, int y, long priority) {
                this.x = x;
                this.y = y;
                this.priority = priority;
            }


            public int compareTo(Data o) {
                int c = Long.compare(priority, o.priority);
                if (c == 0) {
                    c = Integer.compare(x, o.x);
                }
                if (c == 0) {
                    c = Integer.compare(y, o.y);
                }
                return c;
            }

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}