#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int n, m;
int a[101][101];
int tmp[101];
vector<string> ans;
void rotR (int i, int k)
{
ans.push_back ("rotR " + to_string ((long long)i) + " " + to_string ((long long )k));
for (int j=1; j<=m; j++) tmp[j%m] = a[i][j];
for (int j=1; j<=m; j++) a[i][j] = tmp[(j-k+m) % m];
}
void rotC (int j, int k)
{
ans.push_back ("rotC " + to_string ((long long)j) + " " + to_string ((long long )k));
for (int i=1; i<=n; i++) tmp[i%n] = a[i][j];
for (int i=1; i<=n; i++) a[i][j] = tmp[(i-k+n) % n];
}
void negR (int i)
{
ans.push_back ("negR " + to_string ((long long)i));
for (int j=1; j<=m; j++) a[i][j] *= -1;
}
void negC (int j)
{
ans.push_back ("negC " + to_string ((long long)j));
for (int i=1; i<=n; i++) a[i][j] *= -1;
}
void ricacb (int i, int a, int b)
{
if (a>b) swap (a, b);
negC (a);
rotR (i, m-b+a);
negC (a);
rotR (i, b-a);
}
void cirarb (int i, int aa, int b)
{
if (aa>b) swap (aa, b);
negR (aa);
rotC (i, n-b+aa);
negR (aa);
rotC (i, b-aa);
}
void ricjracb (int i, int j, int aa, int b)
{
ricacb (i, b, j);
cirarb (b, i, aa);
}
void negtopos ()
{
int li=-1, lj=-1;
for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) {
if (a[i][j] < 0) {
if (li==-1) {
li = i;
lj = j;
}
else {
ricjracb (i, j, li, lj);
li = lj = -1;
}
}
}
}
int main ()
{
scanf ("%d%d", &n, &m);
for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) scanf ("%d", &a[i][j]);
int nc = 0, zc = 0;
for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) {
if (a[i][j]<0)
nc++;
if (a[i][j]==0)
zc++;
}
if (n%2==0 && m%2==0) {
negtopos ();
int ni=-1, nj=-1, nv;
for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) {
if (a[i][j]<0) {
nv = a[i][j];
ni = i;
nj = j;
}
}
if (ni!=-1) {
int pi=-1, pj=-1, pv=100001;
for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) {
if (a[i][j]>=0 && pv > a[i][j]) {
pv = a[i][j];
pi = i;
pj = j;
}
}
if (-nv > pv)
ricjracb (ni, nj, pi, pj);
}
}
else {
if (nc%2==1) {
if (n%2==1) negC (1);
else negR (1);
}
negtopos ();
}
int s=0;
for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) s += a[i][j];
printf ("%d %d\n", s, ans.size ());
for (int i=0; i<ans.size (); i++)
printf ("%s\n", ans[i].c_str ());
// debug
/*
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++)
printf ("%d ", a[i][j]);
printf ("\n");
}
*/
return 0;
}
/*
3 4
1 -2 5 200
-8 0 -4 -10
11 4 0 100
*/
Compilation message
S.cpp: In function 'void rotR(int, int)':
S.cpp:15:50: error: 'to_string' was not declared in this scope
S.cpp: In function 'void rotC(int, int)':
S.cpp:22:50: error: 'to_string' was not declared in this scope
S.cpp: In function 'void negR(int)':
S.cpp:29:50: error: 'to_string' was not declared in this scope
S.cpp: In function 'void negC(int)':
S.cpp:35:50: error: 'to_string' was not declared in this scope
S.cpp: In function 'int main()':
S.cpp:133:35: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<std::basic_string<char> >::size_type {aka long unsigned int}' [-Wformat]
S.cpp:134:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
S.cpp:84:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
S.cpp:85:74: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]