[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]:
let INF be const integer with INF = 0x3f3f3f3f
define the main function
    let n, m be integers
    read n, m
    let ans, ar be array of size 105 by 105 with ans = ar = {0}
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            read ans[i][j]
            set ar[i][j] to ans[i][j]
        end of the block
    let mins, sum be integers with mins = INF and sum = 0
    let temp be integer array of size 6 by 200 with temp = {0}
    for i = 1 to n inclusive
        set mins to INF
        for j = 1 to m inclusive, set mins to min of mins, ans[i][j]
        set temp[1][i] to mins
        for j = 1 to m inclusive, set ans[i][j] to ans[i][j] - mins
    end of the block
    for j = 1 to m inclusive
        set mins to INF
        for i = 1 to n inclusive, set mins to min of mins, ans[i][j]
        set temp[2][j] to mins
        for i = 1 to n inclusive, decrement ans[i][j] by mins
    end of the block
    for j = 1 to m inclusive
        set mins to INF
        for i = 1 to n inclusive, set mins to min of mins, ar[i][j]
        set temp[3][j] to mins
        for i = 1 to n inclusive, set ar[i][j] to ar[i][j] - mins
    end of the block
    for i = 1 to n inclusive
        set mins to iNF
        for j = 1 to m inclusive, mins = min of mins, ar[i][j]
        temp[4][i] = mins
        for j = 1 to m inclusive, decrement ar[i][j] by mins
    end of the block
    let flag1, flag2 be integers with flag1 = flag2 = 0
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            if ans[i][j] != 0
                set flag1 to 1
                break
            end of the block
        end of the block
    end of the block
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            if ar[i][j] != 0
                set flag2 to 0
                break
            end of the block
        end of the block
    end of the block
    if flag1 == 1 and flag2 == 1
        print -1
    else if flag1 == 0 and flag2 == 0
        sum1 = sum2 = integer = 0
        for i = 1 to n inclusive
            increment sum1 by temp[1][i]
            increment sum2 by temp[4][i]
        end of the block
        for j = 1 to m inclusive
            increment sum1 by temp[2][j]
            increment sum2 by temp[3][j]
        end of the block
        if sum1 > sum2
            print sum2
            for i = 1 to n inclusive
                for j = 1 to temp[4][i], print row, i
            for j = 1 to m inclusive
                for i = 1 to temp[3][j] inclusive, print col, j
        else
            print sum1
            for i = 1 to n inclusive
                for j = 1 to temp[1][i], print "row ", i
            for j = 1 to m inclusive
                for i = 1 to temp[2][j] inclusive, print "col ", j
        end of the block
    else if flag1 == 1
        let sum2 be integer with sum2 = 0
        for i = 1 to n inclusive, increment sum2 by temp[4][i]
        for j = 1 to n inclusive, increment sum2 by temp[3][j]
        print sum2
        for i = 1 to n inclusive
            for j = 1 to temp[4][i] inclusive, print "row ", i
        for j = 1 to m inclusive
            for i = 1 to temp[3][j] inclusive, print "col ", j
    else if flag2 == 1
        sum1 = int = 0
        for i = 1 to n inclusive, increment sum1 by temp[4][i]
        for j = 1 to n inclusive, increment sum1 by temp[3][j]
        print sum1
        for i = 1 to n inclusive
            for j = 1 to temp[1][i] inclusive, print "row ", i
        for j = 1 to m inclusive
            for i = 1 to temp[2][j] inclusive, print "col ", j
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

const int INF = 0x3f3f3f3f;
int main() {
    int n, m;
    cin >> n >> m;
    int ans[105][105] = {0}, ar[105][105] = {0};
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            cin >> ans[i][j];
            ar[i][j] = ans[i][j];
        }
    int mins = INF, sum = 0;
    int temp[6][200] = {0};
    for (int i = 1; i <= n; i++) {
        mins = INF;
        for (int j = 1; j <= m; j++) mins = min(mins, ans[i][j]);
        temp[1][i] = mins;
        for (int j = 1; j <= m; j++) ans[i][j] -= mins;
    }
    for (int j = 1; j <= m; j++) {
        mins = INF;
        for (int i = 1; i <= n; i++) mins = min(mins, ans[i][j]);
        temp[2][j] = mins;
        for (int i = 1; i <= n; i++) ans[i][j] -= mins;
    }
    for (int j = 1; j <= m; j++) {
        mins = INF;
        for (int i = 1; i <= n; i++) mins = min(mins, ar[i][j]);
        temp[3][j] = mins;
        for (int i = 1; i <= n; i++) ar[i][j] -= mins;
    }
    for (int i = 1; i <= n; i++) {
        mins = INF;
        for (int j = 1; j <= m; j++) mins = min(mins, ar[i][j]);
        temp[4][i] = mins;
        for (int j = 1; j <= m; j++) ar[i][j] -= mins;
    }
    int flag1 = 0, flag2 = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (ans[i][j] != 0) {
                flag1 = 1;
                break;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (ar[i][j] != 0) {
                flag2 = 1;
                break;
            }
        }
    }
    if (flag1 == 1 && flag2 == 1)
        cout << -1 << endl;
    else if (flag1 == 0 && flag2 == 0) {
        int sum1 = 0, sum2 = 0;
        for (int i = 1; i <= n; i++) {
            sum1 += temp[1][i];
            sum2 += temp[4][i];
        }
        for (int j = 1; j <= m; j++) {
            sum1 += temp[2][j];
            sum2 += temp[3][j];
        }
        if (sum1 > sum2) {
            cout << sum2 << endl;
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= temp[4][i]; j++) cout << "row " << i << endl;
            for (int j = 1; j <= m; j++)
                for (int i = 1; i <= temp[3][j]; i++) cout << "col " << j << endl;
        } else {
            cout << sum1 << endl;
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= temp[1][i]; j++) cout << "row " << i << endl;
            for (int j = 1; j <= m; j++)
                for (int i = 1; i <= temp[2][j]; i++) cout << "col " << j << endl;
        }
    } else if (flag1 == 1) {
        int sum2 = 0;
        for (int i = 1; i <= n; i++) { sum2 += temp[4][i]; }
        for (int j = 1; j <= m; j++) { sum2 += temp[3][j]; }
        cout << sum2 << endl;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= temp[4][i]; j++) cout << "row " << i << endl;
        for (int j = 1; j <= m; j++)
            for (int i = 1; i <= temp[3][j]; i++) cout << "col " << j << endl;
    } else if (flag2 == 1) {
        int sum1 = 0;
        for (int i = 1; i <= n; i++) { sum1 += temp[4][i]; }
        for (int j = 1; j <= m; j++) { sum1 += temp[3][j]; }
        cout << sum1 << endl;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= temp[1][i]; j++) cout << "row " << i << endl;
        for (int j = 1; j <= m; j++)
            for (int i = 1; i <= temp[2][j]; i++) cout << "col " << j << endl;
    }
    return 0;
}