You are given a matrix of
Operation | Notation | Example |
---|---|---|
Rotate |
rotR |
rotR |
Rotate |
rotS |
rotS |
Multiply all elements in the if and only if none of them were multiplied before. |
negR |
negR |
Multiply all elements in the 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
The next
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
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,
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