On the way to school, Karen became fixated on the puzzle game on her phone! [Image] 

The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.

One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.

To win the level, after all the moves, the number in the cell at the i-th row and j-th column should be equal to g_{i}, j.

Karen is stuck on one level, and wants to know a way to beat this level using the minimum number of moves. Please, help her with this task!


-----Input-----

The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively.

The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains g_{i}, j (0 ≤ g_{i}, j ≤ 500).


-----Output-----

If there is an error and it is actually not possible to beat the level, output a single integer -1.

Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level.

The next k lines should each contain one of the following, describing the moves in the order they must be done:  row x, (1 ≤ x ≤ n) describing a move of the form "choose the x-th row".  col x, (1 ≤ x ≤ m) describing a move of the form "choose the x-th column". 

If there are multiple optimal solutions, output any one of them.


-----Examples-----
Input
3 5
2 2 2 3 2
0 0 0 1 0
1 1 1 2 1

Output
4
row 1
row 1
col 4
row 3

Input
3 3
0 0 0
0 1 0
0 0 0

Output
-1

Input
3 3
1 1 1
1 1 1
1 1 1

Output
3
row 1
row 2
row 3



-----Note-----

In the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: [Image] 

In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is required to only have one 1 in the center.

In the third test case, Karen has a grid with 3 rows and 3 columns. She can perform the following 3 moves to beat the level: [Image] 

Note that this is not the only solution; another solution, among others, is col 1, col 2, col 3.

Difficulty: competition

Starter code:

Solutions:

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n,m=list(map(int,input().split()))

realg=[list(map(int,input().split())) for _ in range(n)]
g=[[0]*m for _ in range(n)]

ans=[]

# get differences
f1=min([realg[0][i] for i in range(m)])
for i in range(m):
    for _ in range(realg[0][i]-f1):
        ans.append("col %d"%(i+1))
    for j in range(n):
        g[j][i]+=realg[0][i]-f1

f2=min([realg[i][0] for i in range(n)])
for i in range(n):
    for _ in range(realg[i][0]-f2):
        ans.append("row %d"%(i+1))
    for j in range(m):
        g[i][j]+=realg[i][0]-f2

# check
bad=0
floor=realg[0][0]-g[0][0]
for i in range(n):
    for j in range(m):
        if realg[i][j]-g[i][j]!=floor:
            bad=1

if bad: print("-1")
else:
    # get floor done
    if n<m:
        for i in range(n):
            for j in range(floor): ans.append("row %d"%(i+1))
    else:
        for i in range(m):
            for j in range(floor): ans.append("col %d"%(i+1))
    print(len(ans))
    print("\n".join(ans))


n,m = input().strip().split()
n,m = int(n),int(m)
g = [[int(j) for j in input().strip().split()] for i in range(n)]

answer =[]

def b():
  for i in range(n):
    minRow = min(g[i])
    if minRow !=0:
      for k in range(minRow):
        answer.append("row " + str(i+1))
      for j in range(m):
        g[i][j] -= minRow
def a():
  for j in range(m):
    minCol = g[0][j]
    for i in range(n):
      if  g[i][j] < minCol:
        minCol = g[i][j]
    if minCol !=0:
      for k in range(minCol):
        answer.append("col " + str(j+1))
      for i in range(n):
        g[i][j] -= minCol


if( n<m):
  b()
  a()
else:
  a()
  b()
maxNumber = max(max(g))
if maxNumber ==0:
  print(len(answer))
  for  el in answer:
    print(el)
else:
  print("-1")

"""Ввод размера матрицы"""
nm = [int(s) for s in input().split()]

"""Ввод массива"""
a = []
for i in range(nm[0]):
    a.append([int(j) for j in input().split()])

rez=[]

def stroka():
    nonlocal rez
    rez_row=[]
    rez_r=0
    for i in range(nm[0]):
        min_row=501
        for j in range(nm[1]):
            if a[i][j]< min_row:
                min_row=a[i][j]
        rez_r+=min_row

        if min_row != 0:
            for c in range(min_row):
                rez.append('row ' + str(i+1))

        for j in range(nm[1]):
            if a[i][j]>0:
                a[i][j]-= min_row

def grafa():
    nonlocal rez
    rez_c=0
    for j in range(nm[1]):
            min_col=501
            for i in range(nm[0]):
                if a[i][j]< min_col:
                    min_col=a[i][j]
            rez_c+=min_col

            if min_col !=0:
                for c in range(min_col):
                    rez.append('col '+ str(j+1))
            for i in range(nm[0]):
                if a[i][j]>0:
                    a[i][j] -=min_col


if nm[0]<nm[1]:
    stroka()
    grafa()
else:
    grafa()
    stroka()

maxEl = max(max(a))

if maxEl == 0:
    print(len(rez))
    for el in rez:
        print(el)
else:
    print(-1)


n,m=list(map(int,input().split()))
a=[]

tot=0

row=[]
col=[]
n1='row'
n2='col'
for _ in range(n):
    a+=[[int(f)for f in input().split()]]
if n>m:
    a=list(map(list,list(zip(*a))))
    n,m=m,n
    n1,n2=n2,n1
for x in range(n):
    for y in range(min(a[x])):
        row+=[x+1]
    tot+=sum(a[x])
for x in range(m):
    t=a[0][x]-min(a[0])
    if t<=0:t=0
    for y in range(t):
        col+=[x+1]
t=len(row)+len(col)
if tot-m*len(row)-n*len(col)==0:
    print(t)
    for x in row:
        print(n1,x)
    for x in col:
        print(n2,x)
else:print(-1)


n, m = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
r = [a[i][0] - a[0][0] for i in range(n)]
c = [a[0][i] - a[0][0] for i in range(m)]
t = min(r)
r = [x - t for x in r]
t = min(c)
c = [x - t for x in c]
p = a[0][0] - r[0] - c[0]
if n < m:
    r = [x + p for x in r]
else:
    c = [x + p for x in c]
for i in range(n):
    for j in range(m):
        if r[i] + c[j] != a[i][j]:
            print(-1)
            quit()
print(sum(r) + sum(c))
for i, x in enumerate(r):
    for j in range(x):
        print("row", i + 1)
for i, x in enumerate(c):
    for j in range(x):
        print("col", i + 1)


x,y=list(map(int,input().split()))
grid=[]

for i in range(x):
    grid.append(list(map(int,input().split())))

mi=grid[0][0]
prints=[]
for i in range(x):
    mi=min(mi,min(grid[i]))

if x > y:
    for k in range(mi):
        for i in range(1,y+1):
            prints.append('col '+str(i))
else:
    for k in range(mi):
        for i in range(1,x+1):
            prints.append('row '+str(i))

for i in range(x):
    for j in range(y):
        grid[i][j]-=mi

for i in range(x):
    while min(grid[i])>0:
        prints.append('row '+str(i+1))
        for j in range(y):
            grid[i][j]-=1
for i in range(y):
    indy=[]
    for ranind in range(x):
        indy.append(grid[ranind][i])
    mindy=min(indy)
    for ran2 in range(mindy):
        prints.append('col '+str(i+1))
        for j in range(x):
            grid[j][i]-=1

ma=grid[0][0]
for i in range(x):
    ma=max(ma,max(grid[i]))
    if ma!=0:
        print('-1')
        quit()

print(len(prints))
print('\n'.join(prints))



(n,m) = (int(i) for i in input().split())
tbl = []
for i in range(n):
	crstr = [int(j) for j in input().split()]
	tbl.append(crstr)
true=0


def prt():
	for xx in range(n):
		for yy in range(m):
			print(tbl[xx][yy], end='	')
		print()
	print()
	print()

# prt()
def lines():
	rows = []
	for i in range(n):
		while 1:
			may = 1
			for j in range(m):
				if tbl[i][j]==0:
					for k in range(j):
						tbl[i][k]+=1
					may = 0
					break
				tbl[i][j]-=1
			if not may: break
			rows.append(i+1)
		# prt()
	return rows

def cols():
	stolbs = []
	for i in range(m):
		while 1:
			may = 1
			for j in range(n):
				if tbl[j][i]==0:
					for k in range(j):
						tbl[k][i]+=1
					may = 0
					break
				tbl[j][i]-=1
			if not may: break
			stolbs.append(i+1)
		# prt()
	return stolbs

if m>n:
	l = lines()
	c = cols()
else:
	c = cols()
	l = lines()

br = 0
for i in range(n):
	for j in range(m):
		if tbl[i][j]!=0:
			br = 1
			break
	if br: break
if br:
	print(-1)
else:
	print(len(l)+len(c))
	for i in l:
		print('row', i)
	for i in c:
		print('col', i)



n, m = map(int, input().split())
g = [list(map(int, input().split())) for i in range(n)]
x, xi, xj = 500, 0, 0
for i, gi in enumerate(g):
    for j, gij in enumerate(gi):
        if gij < x:
            x, xi, xj = gij, i, j
r, c = [g[i][xj] - x for i in range(n)], [g[xi][j] - x for j in range(m)]
for i, gi in enumerate(g):
    for j, gij in enumerate(gi):
        if gij != r[i] + c[j] + x:
            print(-1)
            return
print(min(n, m) * x + sum(r) + sum(c))
for i in range(n):
    for k in range(r[i] + (x if n <= m else 0)):
        print('row', i + 1)
for j in range(m):
    for k in range(c[j] + (x if m < n else 0)):
        print('col', j + 1)

"""Problem A - Karen and Game.

http://codeforces.com/contest/815/problem/A

On the way to school, Karen became fixated on the puzzle game on her phone!

The game is played as follows. In each level, you have a grid with n rows and
m columns. Each cell originally contains the number 0.

One move consists of choosing one row or column, and adding 1 to all of the
cells in that row or column.

To win the level, after all the moves, the number in the cell at the i-th row
and j-th column should be equal to gi, j.

Karen is stuck on one level, and wants to know a way to beat this level using
the minimum number of moves. Please, help her with this task!

Input:

The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the
number of rows and the number of columns in the grid, respectively.

The next n lines each contain m integers. In particular, the j-th integer in
the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).

Output:

If there is an error and it is actually not possible to beat the level, output
a single integer -1.

Otherwise, on the first line, output a single integer k, the minimum number of
moves necessary to beat the level.

The next k lines should each contain one of the following, describing the
moves in the order they must be done:

- row x, (1 ≤ x ≤ n) describing a move of the form "choose the x-th row".

- col x, (1 ≤ x ≤ m) describing a move of the form "choose the x-th column".

If there are multiple optimal solutions, output any one of them.

"""
import logging

ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)

logger = logging.getLogger()
logger.setLevel(logging.ERROR)
logger.addHandler(ch)


def solve(n, m, grid):
    logger.debug('\n'.join([str(x) for x in grid]))

    best_move, best = None, float('inf')
    for z in range(501):
        a = [grid[i][0] - z for i in range(n)]
        b = [z + grid[0][i] - grid[0][0] for i in range(m)]
        logger.debug('z = %s', z)
        logger.debug('a = %s', a)
        logger.debug('b = %s', b)
        if any(x < 0 for x in a + b):
            logger.debug('Non-positives on z %s', z)
            continue
        if any(grid[i][j] != a[i] + b[j] for i in range(n) for j in range(m)):
            logger.warning('Not equal on z %s', z)
            return [-1]
        current = sum(a) + sum(b)
        if current < best:
            best_move = z
            best = current
    logger.debug('Best move is %s', best_move)

    if best_move is None:
        return [-1]

    res = []
    res.append(best)

    a = [grid[i][0] - best_move for i in range(n)]
    for i, times in enumerate(a):
        if not times:
            continue
        res.extend(['row {}'.format(i + 1)] * times)

    b = [best_move + grid[0][i] - grid[0][0] for i in range(m)]
    for i, times in enumerate(b):
        if not times:
            continue
        res.extend(['col {}'.format(i + 1)] * times)

    return res


def main():
    n, m = list(map(int, input().strip().split()))
    grid = [list(map(int, input().strip().split())) for _ in range(n)]
    result = solve(n, m, grid)
    print('\n'.join(map(str, result)))


def __starting_point():
    main()

__starting_point()

"""Codeforces Round #419 (Div. 1) - Karen and Game.

http://codeforces.com/contest/815/problem/A

On the way to school, Karen became fixated on the puzzle game on her phone!

The game is played as follows. In each level, you have a grid with n rows and
m columns. Each cell originally contains the number 0.

One move consists of choosing one row or column, and adding 1 to all of the
cells in that row or column.

To win the level, after all the moves, the number in the cell at the i-th row
and j-th column should be equal to gi, j.

Karen is stuck on one level, and wants to know a way to beat this level using
the minimum number of moves. Please, help her with this task!

Input:

The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the
number of rows and the number of columns in the grid, respectively.

The next n lines each contain m integers. In particular, the j-th integer in
the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).

Output:

If there is an error and it is actually not possible to beat the level, output
a single integer -1.

Otherwise, on the first line, output a single integer k, the minimum number of
moves necessary to beat the level.

The next k lines should each contain one of the following, describing the
moves in the order they must be done:

- row x, (1 ≤ x ≤ n) describing a move of the form "choose the x-th row".

- col x, (1 ≤ x ≤ m) describing a move of the form "choose the x-th column".

If there are multiple optimal solutions, output any one of them.

"""
import logging

ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)

logger = logging.getLogger()
logger.setLevel(logging.ERROR)
logger.addHandler(ch)


def solve(n, m, grid):
    logger.debug('\n'.join([str(x) for x in grid]))

    # Check if ...
    a = [grid[i][0] for i in range(n)]
    b = [grid[0][i] - grid[0][0] for i in range(m)]
    if any(grid[i][j] != a[i] + b[j] for i in range(n) for j in range(m)):
        logger.debug('Not possible ....')
        return [-1]

    best_move, best = None, float('inf')
    for z in range(501):
        a = [grid[i][0] - z for i in range(n)]
        b = [z + grid[0][i] - grid[0][0] for i in range(m)]
        logger.debug('z = %s', z)
        logger.debug('a = %s', a)
        logger.debug('b = %s', b)
        if any(x < 0 for x in a + b):
            logger.debug('Non-positives on z %s', z)
            continue
        current = sum(a) + sum(b)
        if current < best:
            best_move = z
            best = current

    if best_move is None:
        return [-1]

    logger.debug('Best move is %s', best_move)

    res = []
    res.append(best)

    a = [grid[i][0] - best_move for i in range(n)]
    for i, times in enumerate(a):
        if not times:
            continue
        res.extend(['row {}'.format(i + 1)] * times)

    b = [best_move + grid[0][i] - grid[0][0] for i in range(m)]
    for i, times in enumerate(b):
        if not times:
            continue
        res.extend(['col {}'.format(i + 1)] * times)

    return res


def main():
    n, m = list(map(int, input().strip().split()))
    grid = [list(map(int, input().strip().split())) for _ in range(n)]
    result = solve(n, m, grid)
    print('\n'.join(map(str, result)))


def __starting_point():
    main()

__starting_point()

#815A

inpt = input().split(" ")
n = int(inpt[0])
m = int(inpt[1])

arr = []

for i in range(n):
	inpt = input().split(" ")
	inpt = list(map(int, inpt))
	arr.append(inpt)

sol = []

def solver1(a, sol):
	allmin = min([min(suba) for suba in a])
	if allmin < 0:
		return False
	allmax = max([max(suba) for suba in a])
	if allmax == 0:
		return True
	else:
		for i in range(len(a)):
			p = min(a[i])
			if p > 0:
				for j in range(len(a[i])):
					a[i][j] -= p
				for q in range(p):
					sol.append(i + 1)
				return solver1(a, sol)
		for j in range(len(a[0])):
			b = []
			for i in range(len(a)):
				b.append(a[i][j])
			p = min(b)
			if p > 0:
				for k in range(len(b)):
					a[k][j] -= p
				for q in range(p):
					sol.append(len(a) + j + 1)
				return solver1(a, sol)

def solver2(a, sol):
	allmin = min([min(suba) for suba in a])
	if allmin < 0:
		return False
	allmax = max([max(suba) for suba in a])
	if allmax == 0:
		return True
	else:
		for j in range(len(a[0])):
			b = []
			for i in range(len(a)):
				b.append(a[i][j])
			p = min(b)
			if p > 0:
				for k in range(len(b)):
					a[k][j] -= p
				for q in range(p):
					sol.append(len(a) + j + 1)
				return solver2(a, sol)
		for i in range(len(a)):
			p = min(a[i])
			if p > 0:
				for j in range(len(a[i])):
					a[i][j] -= p
				for q in range(p):
					sol.append(i + 1)
				return solver2(a, sol)

if n < m:
	if solver1(arr, sol):
		print(len(sol))
		for i in sol:
			if i <= n:
				print("row", i)
			else:
				print("col", i - n)
	else:
		print("-1")
else:
	if solver2(arr, sol):
		print(len(sol))
		for i in sol:
			if i <= n:
				print("row", i)
			else:
				print("col", i - n)
	else:
		print("-1")

def main():
    n, m = list(map(int, input().split()))
    l, r = [list(map(int, input().split())) for _ in range(n)], []
    if n > m:
        l = [list(col) for col in zip(*l)]
        cols, rows = 'row %d', 'col %d'
    else:
        cols, rows = 'col %d', 'row %d'
    for y, row in enumerate(l, 1):
        a = min(row)
        for i, t in enumerate(row):
            row[i] = t - a
        r += [rows % y] * a
    l = [list(col) for col in zip(*l)]
    for x, col in enumerate(l, 1):
        a = min(col)
        for i, t in enumerate(col):
            col[i] = t - a
        r += [cols % x] * a
    r.append(str(len(r)))
    print(-1 if any(map(any, l)) else '\n'.join(r[::-1]))


def __starting_point():
    main()

__starting_point()

n, m = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
r = [a[i][0] - a[0][0] for i in range(n)]
c = [a[0][i] - a[0][0] for i in range(m)]
t = min(r)
r = [x - t for x in r]
t = min(c)
c = [x - t for x in c]
p = a[0][0] - r[0] - c[0]
if n < m:
    r = [x + p for x in r]
else:
    c = [x + p for x in c]
for i in range(n):
    for j in range(m):
        if r[i] + c[j] != a[i][j]:
            print(-1)
            quit()
print(sum(r) + sum(c))
for i, x in enumerate(r):
    for j in range(x):
        print("row", i + 1)
for i, x in enumerate(c):
    for j in range(x):
        print("col", i + 1)




# Made By Mostafa_Khaled


n,m=list(map(int,input().split()))
L=[list(map(int,input().split())) for i in range(n)]
s="row"
s1="col"
if n>m :
    L1=[[0 for i in range(n)] for j in range(m)]
    for i in range(n) :
        for j in range(m) :
            L1[j][i]=L[i][j]
    L=L1
    n,m=m,n
    s,s1=s1,s
            
w=[0 for i in range(n)]
w1=[0 for i in range(m)]
for i in range(n) :
    w[i]=min(L[i])
for i in range(m) :
    for j in range(n) :
        ma=0
        ma=max(L[j][i]-w[j],ma)
    w1[i]=ma
for i in range(n) :
    for j in range(m) :
        if L[i][j]-w[i]-w1[j]!=0 :
            print(-1)
            return
otv=[]
for i in range(n) :
    otv+=[s+" "+str(i+1)]*w[i]
for i in range(m) :
    otv+=[s1+" "+str(i+1)]*w1[i]
print(len(otv))
print('\n'.join(otv))
            


    
    
        
    
    


class CodeforcesTask815ASolution:
    def __init__(self):
        self.result = ''
        self.n_m = []
        self.board = []

    def read_input(self):
        self.n_m = [int(x) for x in input().split(" ")]
        for x in range(self.n_m[0]):
            self.board.append([int(y) for y in input().split(" ")])

    def process_task(self):
        columns = []
        for x in range(self.n_m[1]):
            column = []
            for y in range(self.n_m[0]):
                column.append(self.board[y][x])
            columns.append(column)

        left_board_moves = [min(row) for row in self.board]
        bottom_board_moves = [min(column) for column in columns]
        reduce1 = min(bottom_board_moves)
        reduce2 = min(left_board_moves)
        if reduce1 * self.n_m[0] > reduce2 * self.n_m[1]:
            left_board_moves = [x - reduce1 for x in left_board_moves]
        else:
            bottom_board_moves = [x - reduce2 for x in bottom_board_moves]
        moves = sum(left_board_moves) + sum(bottom_board_moves)
        board_score = sum(left_board_moves) * self.n_m[1] + sum(bottom_board_moves) * self.n_m[0]
        real_board_score = sum([sum(x) for x in self.board])
        if board_score != real_board_score:
            self.result = "-1"
        else:
            print("{0}".format(moves))
            for x in range(self.n_m[0]):
                for y in range(left_board_moves[x]):
                    print("row {0}".format(x + 1))
            for x in range(self.n_m[1]):
                for y in range(bottom_board_moves[x]):
                    print("col {0}".format(x + 1))

    def get_result(self):
        return self.result


def __starting_point():
    Solution = CodeforcesTask815ASolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())

__starting_point()

n, m = map(int, input().split())

array = []
row_sums = [0 for x in range(n)]

for i in range(n):
	array.append(list(map(int, input().split())))
	row_sums[i] = sum(array[i])

col_sums = [sum(x) for x in zip(*array)]

min_row_index = row_sums.index(min(row_sums))
min_col_index = col_sums.index(min(col_sums))


row_boost = [0 for x in range(n)]
col_boost = [0 for x in range(m)]
#rows contribute more
if n <= m:
	#get largest row add possible
	col_boost[min_col_index] = 0
	for i in range(m):
		if i != min_col_index:
			col_boost[i] = (col_sums[i] - col_sums[min_col_index]) // n

		sum_col_boosts = sum(col_boost)

		for i in range(n):
			row_boost[i] = (row_sums[i] - sum_col_boosts) // m

if n >= m:
	row_boost[min_row_index] = 0

	for i in range(n):
		if i != min_row_index:
			row_boost[i] = (row_sums[i] - row_sums[min_row_index]) // m

	sum_row_boosts = sum(row_boost)

	for i in range(m):
		col_boost[i] = (col_sums[i] - sum_row_boosts) // n

for row in range(n):
	if [row_boost[row] + c for c in col_boost] != array[row]:
		print(-1)
		return

print(sum(row_boost + col_boost))
for i in range(n):
	for count in range(row_boost[i]):
		print('row ' + str(i+1))

for j in range(m):
	for count in range(col_boost[j]):
		print('col ' + str(j+1))

n, m = map(int, input().split())
grid = [list(map(int, input().split())) for i in range(n)]
ans = []
if m > n:
    for i in range(n):
        mini = min(grid[i])
        for j in range(m):
            grid[i][j] -= mini
        for _ in range(mini):
            ans.append("row " + str(i+1))
    for i in range(m):
        mini = float('inf')
        for j in range(n):
            mini = min(grid[j][i], mini)
        for j in range(n):
            grid[j][i] -= mini
        for _ in range(mini):
            ans.append("col " + str(i+1))
else:
    for i in range(m):
        mini = float('inf')
        for j in range(n):
            mini = min(grid[j][i], mini)
        for j in range(n):
            grid[j][i] -= mini
        for _ in range(mini):
            ans.append("col " + str(i+1))
    for i in range(n):
        mini = min(grid[i])
        for j in range(m):
            grid[i][j] -= mini
        for _ in range(mini):
            ans.append("row " + str(i+1))
if all([sum(i) == 0 for i in grid]):
    print(len(ans))
    for i in ans:
        print(i)
else:
    print(-1)

#!/usr/bin/env pypy3

def all_zero(A):
    for row in A:
        for e in row:
            if e != 0: return False
    return True

n, m = input().split(' ')
n = int(n)
m = int(m)

A = []

for _ in range(n):
    row = input().split(' ')
    row = list(map(int, row))
    A += [row]

moves = []

# produce a zero

min_elem = min(min(row) for row in A)

if min_elem > 0:
    if m >= n:
        for x in range(n):
            moves += [f"row {x+1}"]*min_elem
    else:
        for y in range(m):
            moves += [f"col {y+1}"]*min_elem

    for x in range(n):
        for y in range(m):
            A[x][y] -= min_elem

pivot = None

for x in range(n):
    for y in range(m):
        if A[x][y] == 0:
            pivot = (x, y)
            break

assert(pivot is not None)

pivot_x, pivot_y = pivot

for x in range(n):
    if x == pivot_x: continue
    f = A[x][pivot_y]
    moves += [f"row {x+1}"]*f
    for y in range(m):
        A[x][y] -= f

for y in range(m):
    if y == pivot_y: continue
    f = A[pivot_x][y]
    moves += [f"col {y+1}"]*f
    for x in range(n):
        A[x][y] -= f

if not all_zero(A):
    print(-1)
else:
    print(len(moves))
    print('\n'.join(moves))


def min_row():
    ans = 0
    for i in range(n):
        ans += min(a[i])
    return ans


def min_col():
    ans = 0
    for i in range(m):
        mm = 10000
        for j in range(n):
            mm = min(mm, a[j][i])
        ans += mm
    return ans


def remove_cols():
    ans = 0
    min_col = [0] * m
    for i in range(m):
        min_col[i] = 1000
        for j in range(n):
            min_col[i] = min(min_col[i], a[j][i])
        ans += min_col[i]
        for j in range(n):
            a[j][i] -= min_col[i]
    return ans, min_col


def remove_rows():
    ans = 0
    min_row = []
    for i in range(n):
        min_row.append(min(a[i]))
        ans += min_row[-1]
        for j in range(m):
            a[i][j] -= min_row[i]
    return ans, min_row


n, m = list(map(int, input().split()))
a = []
s = 0

for i in range(n):
    row = list(map(int, input().split()))
    a.append(row)
    s += sum(row)

rows = min_row()
cols = min_col()

if rows == 0 and cols == 0:
    if s == 0:
        print(0)
        return
    else:
        print(-1)
        return

if cols == 0 or (rows != 0 and (s - rows * m) % n == 0 and ((s - cols * n) % m != 0 or (s - rows * m) // n + rows < (s - cols * n) // m + cols)):
    ans, min_row = remove_rows()
    ans1, min_col = remove_cols()
else:
    ans1, min_col = remove_cols()
    ans, min_row = remove_rows()

ans += ans1

for row in a:
    for ai in row:
        if ai != 0:
            print(-1)
            return

print(ans)
for i in range(n):
    for j in range(min_row[i]):
        print("row", i + 1)
for i in range(m):
    for j in range(min_col[i]):
        print("col", i + 1)