
function Main(input)
{
	input = input.split("\n");
	var count = parseInt(input[0]);
	var data = [];
	var player = new Array(Math.pow(3, count));
	
	for(var cnt = 0; cnt < player.length; cnt ++)
	{
		player[cnt] = cnt;
	}

	for(var cnt = 0; cnt < input[1].length; cnt ++)
	{
		if (input[1].charAt(cnt) == "S")
		{
			for(var cnt2 = 0; cnt2 < player.length; cnt2 ++)
			{
				
				var two = parseInt(player[cnt2]).toString(3);

				var twoT = "";

				for(var cnt3 = 0; cnt3 < two.length; cnt3 ++)
				{
					twoT += two.charAt(cnt3) == "2" ? "1" : two.charAt(cnt3) == "1" ? "2" : "0";
				}
				
				var nextPos = parseInt(twoT, 3);

				player[cnt2] = nextPos;
				
				
			}
		}else{ //R
			for(var cnt2 = 0; cnt2 < player.length; cnt2 ++)
			{
				player[cnt2] ++;
				player[cnt2] = player[cnt2] % player.length;
			}	
		}
		var newPlayer = new Array(player.length);

		for(var cnt2 = 0; cnt2 < player.length; cnt2 ++)
		{
			newPlayer[player[cnt2]] = cnt2;
		}
	}

	console.log(player.join(" "));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
