Олимпиадный тренинг

Задача 38370. Table


Задача

Темы:
In the new single-player math game "Table of Numbers" a table of size n rows by m columns is used, filled with integers. In one move, the player chooses one of the rows or one of the columns and reverses the sign of all the numbers in this row or column.

The goal of the game is to bring the table into such a form that the sum of the numbers in each row and each column is non-negative. At the same time, it is not required to minimize the number of moves, but you can make no more than 20,000 moves.

Your task is to write a program that, given the description of the initial form of the table, will find a sequence of moves that leads to the achievement of the goal of the game, or determines that the goal of the game is unattainable.

Input
The first line of the input file contains two integers: n and m (2 ≤ n, m ≤ 100). Each of the next n lines contains m integers ai,j (|ai,j| ≤ 100).

Imprint
In the first line of the output file print k — the number of moves to be made, or "-1" if the goal of the game cannot be achieved. In the first case, on the next k lines print a description of these moves.

The description of each move should be displayed on a separate line, which should contain: the type of move ("R" — on this move a row is selected or "C" — on this move a column is selected) and the number of the corresponding row or column. Rows and columns are numbered with natural numbers starting from one, rows are numbered from top to bottom, and columns — from left to right.

The sequence of moves output by your program must contain no more than 20,000 moves. It is guaranteed that if there is a sequence of moves leading to the goal of the game, then there is a sequence that satisfies the specified constraint
Examples
# Input Output
1 2 2
-1 -3
1-2
1
C2
2 3 2
-1 -1
-1 -1
-1 -1
3
R1
R2
R3