program grozavesti;
var m : array [1..300,1..300] of longint;
i1,i2 : array [1..600] of longint;
c: array [1..600] of char;
fin, fout : text;
n, i, j, cl, ln, changes: longint;
procedure schc(c1,c2:longint);
var i,aux : longint;
begin
for i := 1 to n do
begin
aux := m[i,c1];
m[i,c1]:=m[i,c2];
m[i,c2]:=aux;
end;
changes := changes+1;
c[changes]:='C';
i1[changes]:= c1;
i2[changes]:= c2;
end;
procedure schl(l1,l2:longint);
var i,aux : longint;
begin
for i := 1 to n do
begin
aux := m[l1,i];
m[l1,i]:=m[l2,i];
m[l2,i]:=aux;
end;
changes := changes+1;
c[changes]:='L';
i1[changes]:= l1;
i2[changes]:= l2;
end;
procedure min (start:longint);
var i,j,mi,c,l : longint;
begin
mi:=m[start,start]; c := start; l :=start;
for i := start to n do
for j := start to n do
if m[i,j]< mi then
begin
mi := m[i,j];
c:= j;
l:= i;
end;
ln := l; cl := c;
end;
begin
assign(fin,'grozavesti.in'); reset(fin);
assign(fout,'grozavesti.out'); rewrite(fout);
readln(fin,n);
for i := 1 to n do
for j := 1 to n do
read(fin,m[i,j]);
changes := 0;
for i := 1 to n-1 do
begin
min(i);
if cl <> i then
schc(i,cl);
if ln <> i then
schl(i,ln);
end;
writeln(fout,changes);
for i := 1 to changes do
writeln(fout,c[i],' ',i1[i],' ',i2[i]);
close(fout);
close(fin);
end.