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 C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 20
#define M 221
ll d[N][N];
ll g[M+10][M+10];
ll gg[M][M];

int main(){
	ll a, b;
	cin>>a>>b;
	rep1(i, a) rep1(j, b) cin>>d[i][j];
	mset(g, -1);
	bool ng = false;
	rep1(i, a-1) rep1(j, b-1){
		if(d[i+1][j]-d[i][j]<0) ng = true;
		if(d[i][j+1]-d[i][j]<0) ng = true;
		if(i+2<=a&&(d[i+1][j]-d[i][j]<d[i+2][j]-d[i+1][j])) ng = true;
		if(j+2<=b&&(d[i][j+1]-d[i][j]<d[i][j+2]-d[i][j+1])) ng = true;
	}
	if(ng){
		cout<<"Impossible"<<endl;
		return 0;
	}
	ll m = 200;
	for(ll i = a; i >= 1; i--){
		for(ll j = b; j >= 1; j--){
			ll x = 0, y = 0;
			for(int k = i; k <= a; k++) for(int l = j; l <= b; l++){
				if(k>i) chmax(x, (d[k][j]-d[i][j]+k-i-1)/(k-i));
				if(l>j) chmax(y, (d[i][k]-d[i][j]+k-j-1)/(k-j));
			}

			//for(int k = j+1; k <= b; k++) chmax(y, (d[i][k]-d[i][j]+k-j-1)/(k-j));
			//ll x = i<a?(d[a][j]-d[i][j]+a-i)/(a-i):0;
			//ll y = j<b?(d[i][b]-d[i][j]+b-j)/(b-j):0;
			ll c = d[i][j]-x*i-y*j;
			//cerr<<i<<" "<<j<<endl;
			//cerr<<x<<" "<<y<<" "<<c<<endl;
			if(x<0||y<0||/*(g[x+1][201-y]!=-1)||*/(c<0||c>100)){
				cout<<"Impossible"<<endl;
				return 0;
			}
			if(g[x+1][201-y]==-1) m++;
			chmax(g[x+1][201-y], c);
			//cerr<<x<<" "<<y<<" "<<c<<endl;
		}
	}
	rep1(i, a) rep1(j, b){
		rep(i2, M) fill(gg[i2], gg[i2]+M, INF);
		rep(i2, M) gg[i2][i2] = 0;
		REP(i2, 1, 101) gg[i2][i2+1] = i;
		REP(i2, 101, 201) gg[i2][i2+1] = j;
		rep(i2, M) rep(j2, M) if(g[i2][j2]!=-1) gg[i2][j2] = g[i2][j2];
		rep(k, M) rep(i2, M) rep(j2, M) chmin(gg[i2][j2], gg[i2][k]+gg[k][j2]);
		if(gg[1][201]!=d[i][j]){
			cout<<"Impossible"<<endl;
			return 0;
		}
	}
	cout<<"Possible"<<endl;
	cout<<201<<" "<<m<<endl;
	for(ll i = 1; i <= 100; i++) cout<<i<<" "<<i+1<<" X"<<endl;
	for(ll i = 101; i <= 200; i++) cout<<i<<" "<<i+1<<" Y"<<endl;
	rep(i, M) rep(j, M) if(g[i][j]!=-1) cout<<i<<" "<<j<<" "<<g[i][j]<<endl;
	cout<<"1 201"<<endl;
	return 0;
}