You are given a matrix of rows and columns. All elements of the matrix are by their absolute value smaller than or equal to . You may perform the following operations:
Operation | Notation | Example |
---|---|---|
Rotate -th row of the matrix elements right | rotR | rotR |
Rotate -th column of the matrix elements down | rotS | rotS |
Multiply all elements in the -th row by , if and only if none of them were multiplied before. |
negR | negR |
Multiply all elements in the -th column by , if and only if none of them were multiplied before. |
negS | negS |
Using a limited number of these operations, you need to maximize the sum of all the elements of the matrix.
Input Specification
The first line of input contains two integers and , number of rows and columns.
The next lines contain integers each. All integers are by their absolute value smaller than .
Output Specification
The first line of output should contain two integers, the maximal sum obtainable and the number of operations used. We shall call this number .
The next lines should contain any sequence of operations leading to the sum. Each operation should follow the notation defined in the table below. For details look at sample test cases.
If the obtained sum is not maximal, one of the elements was multiplied more than once or the sequence of operations printed does not lead to the sum, points are awarded.
Otherwise, the number of points depends on the number of operations used
- For , you are awarded of points allocated to that test case
- For , you are awarded of points allocated to that test case
- For , you are awarded points for that test case
Sample Input 1
3 4
1 -2 5 200
-8 0 -4 -10
11 4 0 100
Sample Output 1
345 2
rotS 2 1
negR 2
Sample Input 2
3 3
8 -2 7
1 0 -3
-4 -8 3
Sample Output 2
34 4
rotR 1 1
rotS 3 1
negR 2
negR 3
Comments