function IntToStr(n: Longint): String;
var s: String;
begin
Str(n,s); IntToStr:=s;
end;
var
lr: array [0..2] of String;
n, k: Longint;
t: Integer;
begin
Read(n); k:=1;
while n<>0 do begin
t:=n mod 3; if t<>0 then lr[t]:=lr[t]+' '+IntToStr(k);
n:=n div 3; k:=k*3;
end;
WriteLn('L',lr[2]); WriteLn('R',lr[1]);
end.
var s: String;
begin
Str(n,s); IntToStr:=s;
end;
var
lr: array [0..2] of String;
n, k: Longint;
t: Integer;
begin
Read(n); k:=1;
while n<>0 do begin
t:=n mod 3; if t<>0 then lr[t]:=lr[t]+' '+IntToStr(k);
n:=n div 3; k:=k*3;
end;
WriteLn('L',lr[2]); WriteLn('R',lr[1]);
end.