Problem:
Score : 900 points

Problem Statement

AtCoDeer the deer wants a directed graph that satisfies the following conditions:

The number of vertices, N, is at most 300.

There must not be self-loops or multiple edges.

The vertices are numbered from 1 through N.

Each edge has either an integer weight between 0 and 100 (inclusive), or a label X or Y.

For every pair of two integers (x,y) such that 1 ≤ x ≤ A, 1 ≤ y ≤ B,
the shortest distance from Vertex S to Vertex T in the graph where the edges labeled X have the weight x and the edges labeled Y have the weight y, is d_{x,y}.

Construct such a graph (and a pair of S and T) for him, or report that it does not exist.
Refer to Output section for output format.

Constraints

1 ≤ A,B ≤ 10

1 ≤ d_{x,y} ≤ 100 (1 ≤ x ≤ A, 1 ≤ y ≤ B)

All input values are integers.

Input

Input is given from Standard Input in the following format:

A B
d_{1,1} d_{1,2} .. d_{1,B}
d_{2,1} d_{2,2} .. d_{2,B}
:
d_{A,1} d_{A,2} .. d_{A,B}

Output

If no graph satisfies the condition, print Impossible.

If there exists a graph that satisfies the condition, print Possible in the first line.
Then, in the subsequent lines, print the constructed graph in the following format:

N M
u_1 v_1 c_1
u_2 v_2 c_2
:
u_M v_M c_M
S T

Here, M is the number of the edges, and u_i, v_i, c_i represent edges as follows: there is an edge from Vertex u_i to Vertex v_i whose weight or label is c_i.

Also refer to Sample Outputs.

Sample Input 1

2 3
1 2 2
1 2 3

Sample Output 1

Possible
3 4
1 2 X
2 3 1
3 2 Y
1 3 Y
1 3

Sample Input 2

1 3
100 50 1

Sample Output 2

Impossible

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.Reader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyInput in = new MyInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, MyInput in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int[][] d = new int[a][b];
            int[][] useX = new int[a - 1][b];
            int[][] useY = new int[a][b - 1];
            int maxX = 0;
            int maxY = 0;
            for (int i = 0; i < a; i++) {
                for (int j = 0; j < b; j++) {
                    d[i][j] = in.nextInt();
                    if (i > 0) {
                        useX[i - 1][j] = d[i][j] - d[i - 1][j];
                        if (useX[i - 1][j] < 0) {
                            out.println("Impossible");
                            return;
                        }
                        maxX = Math.max(maxX, useX[i - 1][j]);
                    }
                    if (j > 0) {
                        useY[i][j - 1] = d[i][j] - d[i][j - 1];
                        if (useY[i][j - 1] < 0) {
                            out.println("Impossible");
                            return;
                        }
                        maxY = Math.max(maxY, useY[i][j - 1]);
                    }
                }
            }
            for (int i = a - 2; i >= 0; i--) {
                for (int j = b - 2; j >= 0; j--) {
                    if (i < a - 1) {
                        useX[i][j] += useX[i][j + 1];
                    }
                    if (j < b - 1) {
                        useY[i][j] += useY[i + 1][j];
                    }
//                if (i < a-2 && j < b-2) { useX[i][j] -= useY[i+1][j+1]; useX[i][j] -= useY[i+1][j+1]; }
                }
            }

            int cur = 0;
            int S = cur++;
            int[][] g = new int[300][300];
            for (int[] gg : g) Arrays.fill(gg, Integer.MIN_VALUE);
            for (int i = 0; i < maxX; i++) {
                g[cur - 1][cur] = -1;
                cur++;
            }
            g[cur - 1][cur] = 100;
            cur++;
            for (int i = 0; i < maxY; i++) {
                g[cur - 1][cur] = -2;
                cur++;
            }
            int T = cur - 1;
            for (int i = 0; i < a; i++) {
                for (int j = 0; j < b; j++) {
                    if (i < a - 1 && j < b - 1) {
                        int xi = useX[i][j];
                        int yi = T - useY[i][j];
                        int c = d[i][j] - (i + 1) * useX[i][j] - (j + 1) * useY[i][j];
                        if (c < 0) {
                            out.println("Impossible");
                            return;
                        }
                        g[xi][cur] = c;
                        g[cur++][yi] = 0;
                    } else if (i < a - 1) {
                        int xi = useX[i][j];
                        int c = d[i][j] - (i + 1) * useX[i][j];
                        if (c < 0) {
                            out.println("Impossible");
                            return;
                        }
                        g[xi][cur] = c;
                        g[cur++][T] = 0;
                    } else if (j < b - 1) {
                        int yi = T - useY[i][j];
                        int c = d[i][j] - (j + 1) * useY[i][j];
                        if (c < 0) {
                            out.println("Impossible");
                            return;
                        }
                        g[S][cur] = c;
                        g[cur++][yi] = 0;
                    } else {
                        g[S][cur] = d[i][j];
                        g[cur++][T] = 0;
                    }
                }
            }

            int e = 0;
            for (int i = 0; i < g.length; i++) {
                for (int j = 0; j < g.length; j++) {
                    if (g[i][j] != Integer.MIN_VALUE) {
                        e++;
                    }
                }
            }

            out.println("Possible");
            out.println(cur + " " + e);
            for (int i = 0; i < g.length; i++) {
                for (int j = 0; j < g.length; j++) {
                    if (g[i][j] != Integer.MIN_VALUE) {
                        if (g[i][j] == -1) out.println((i + 1) + " " + (j + 1) + " X");
                        if (g[i][j] == -2) out.println((i + 1) + " " + (j + 1) + " Y");
                        if (g[i][j] >= 0) out.println((i + 1) + " " + (j + 1) + " " + g[i][j]);
                    }
                }
            }
            out.println((S + 1) + " " + (T + 1));
        }

    }

    static class MyInput {
        private final BufferedReader in;
        private static int pos;
        private static int readLen;
        private static final char[] buffer = new char[1024 * 8];
        private static char[] str = new char[500 * 8 * 2];
        private static boolean[] isDigit = new boolean[256];
        private static boolean[] isSpace = new boolean[256];
        private static boolean[] isLineSep = new boolean[256];

        static {
            for (int i = 0; i < 10; i++) {
                isDigit['0' + i] = true;
            }
            isDigit['-'] = true;
            isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
            isLineSep['\r'] = isLineSep['\n'] = true;
        }

        public MyInput(InputStream is) {
            in = new BufferedReader(new InputStreamReader(is));
        }

        public int read() {
            if (pos >= readLen) {
                pos = 0;
                try {
                    readLen = in.read(buffer);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (readLen <= 0) {
                    throw new MyInput.EndOfFileRuntimeException();
                }
            }
            return buffer[pos++];
        }

        public int nextInt() {
            int len = 0;
            str[len++] = nextChar();
            len = reads(len, isSpace);
            int i = 0;
            int ret = 0;
            if (str[0] == '-') {
                i = 1;
            }
            for (; i < len; i++) ret = ret * 10 + str[i] - '0';
            if (str[0] == '-') {
                ret = -ret;
            }
            return ret;
        }

        public char nextChar() {
            while (true) {
                final int c = read();
                if (!isSpace[c]) {
                    return (char) c;
                }
            }
        }

        int reads(int len, boolean[] accept) {
            try {
                while (true) {
                    final int c = read();
                    if (accept[c]) {
                        break;
                    }
                    if (str.length == len) {
                        char[] rep = new char[str.length * 3 / 2];
                        System.arraycopy(str, 0, rep, 0, str.length);
                        str = rep;
                    }
                    str[len++] = (char) c;
                }
            } catch (MyInput.EndOfFileRuntimeException e) {
            }
            return len;
        }

        static class EndOfFileRuntimeException extends RuntimeException {
        }

    }
}