[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
len=1005
mod=998244353
seed=131
r,c=array of len int
dd=array of len by len int
num,n,m
flag=int
function solve1 (no args, no return value)
    for i=1 to n inclusive
        minx=10^9
        for j=1 to m inclusive minx=min(minx,dd[i][j])
        r[i]=minx
        if r[i] is not 0 add minx to num
        for j=1 to m inclusive subtract minx from dd[i][j]
    end of the block
    for j=1 to m inclusive
        minx=10^9
        for i=1 to n inclusive minx=min(minx,dd[i][j])
        c[j]=minx
        if minx is not 0 add minx to num
        for i=1 to n inclusive
            subtract minx from dd[i][j]
            if dd[i][j] flag=1
        end of the block
    end of the block
end of the block
function solve1 (no args, no return value)
    for j=1 to m inclusive
        minx=10^9
        for i=1 to n inclusive minx=min(minx,dd[i][j])
        c[j]=minx
        if minx is not 0 add minx to num
        for i=1 to n inclusive subtract minx from dd[i][j]
    end of the block
    for i=1 to n inclusive
        minx=10^9
        for j=1 to m inclusive minx=min(minx,dd[i][j])
        r[i]=minx
        if r[i] is not 0 add minx to num
        for j=1 to m inclusive
            subtract minx from dd[i][j]
            if dd[i][j] flag=1
        end of the block
    end of the block
end of the block
define the main function
    read n,m
    for i=1 to n inclusive
        for j=1 to m inclusive read dd[i][j]
    if n<=m
        solve1()
    else
        solve2()
    if flag print -1 and return 0
    print num
    for i=1 to n inclusive
        for j=0 to r[i] exclusive print "row ", i
    end of the block
    for i=1 to m inclusive
        for j=0 to c[i] exclusive print "col ", i
end of the block

[CODE]:

const int len = 1e3 + 5;
const long long mod = 998244353;
const ulong long seed = 131;
int r[len], c[len];
int dd[len][len];
int num, n, m;
int flag;
void solve1() {
    for (int i = 1; i <= n; ++i) {
        int minx = 1e9;
        for (int j = 1; j <= m; ++j) minx = min(minx, dd[i][j]);
        r[i] = minx;
        if (r[i] != 0) num += minx;
        for (int j = 1; j <= m; ++j) dd[i][j] -= minx;
    }
    for (int j = 1; j <= m; ++j) {
        int minx = 1e9;
        for (int i = 1; i <= n; ++i) minx = min(minx, dd[i][j]);
        c[j] = minx;
        if (minx != 0) num += minx;
        for (int i = 1; i <= n; ++i) {
            dd[i][j] -= minx;
            if (dd[i][j]) flag = 1;
        }
    }
}
void solve2() {
    for (int j = 1; j <= m; ++j) {
        int minx = 1e9;
        for (int i = 1; i <= n; ++i) minx = min(minx, dd[i][j]);
        c[j] = minx;
        if (minx != 0) num += minx;
        for (int i = 1; i <= n; ++i) dd[i][j] -= minx;
    }
    for (int i = 1; i <= n; ++i) {
        int minx = 1e9;
        for (int j = 1; j <= m; ++j) minx = min(minx, dd[i][j]);
        r[i] = minx;
        if (r[i] != 0) num += minx;
        for (int j = 1; j <= m; ++j) {
            dd[i][j] -= minx;
            if (dd[i][j]) flag = 1;
        }
    }
}
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) cin >> dd[i][j];
    if (n <= m)
        solve1();
    else
        solve2();
    if (flag) return puts("-1"), 0;
    cout << num << endl;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < r[i]; ++j) cout << "row " << i << endl;
    }
    for (int i = 1; i <= m; ++i)
        for (int j = 0; j < c[i]; ++j) cout << "col " << i << endl;
}