$|=1;
sub i{$_=<>;/M/&&exit;$_+0}
sub o{print"@_\n"}
o F while i>0;
while(1){o F;i;o R;o L while!i}