Innoforest
Trees in Innopolis are exceptional, if you water an innotree (Innopolis Tree), it will grow by number of litres you have watered it. In other words if you water innotree of height h by x litres of water then it will have new height of h + x.
Innoforest (Innopolis Forest) is a n * m grid, each cell of the grid contains one innotree. Irrigation system in innoforest contains n + m canals: one for each row and column. The irrigation system in one operation can water all trees along one of canals by the same amount of water.
The mayor of Innopolis wants to transform the innoforest by performing some operations on the irrigation system. For each tree in innoforest you know its current height and the desired height. Your task is to find the sequence of operations that transforms the innoforest to the desired shape.
Input
First line contains two numbers n and m (1 ≤ n, m ≤ 1000) - the size of innoforest.
Then n lines follow, each line contains m numbers a[i,j]
(1 ≤ a[i,j]
≤ 10^9
), current heights of the trees in innoforest.
Then n more lines follow, each line contains m numbers b[i,j]
(1 ≤ b[i,j]
≤ 10^9
), desired heights of the trees.
Output
The first line should contain the number of operations k (0 ≤ k ≤ 10^6
), then k lines contain the description of operations.
"R r x" The system will water the r-th row by x litres (1 ≤ r ≤ n, 1 ≤ x ≤
10^9
)."C c x" The system will water the c-th column by x litres (1 ≤ c ≤ m, 1 ≤ x ≤
10^9
).
If it is impossible to transform the innoforest to the desired shape, output only one integer -1.
Notice that it is not required to minimize the number of operations, only make sure that it does not exceed 10^6
.