
function Main(input)
{
	input = input.split("\n");
	var count = parseInt(input[0]);
	var data = [];
	
	for(var cnt = 0; cnt < input[1].length; cnt ++)
	{
		data.push(input[1].substr(cnt, 1));
	}

	var player = new Array(Math.pow(3, count));
	
	for(var cnt = 0; cnt < player.length; cnt ++)
	{
		player[cnt] = cnt;
	}

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

				for(var cnt3 = 0; cnt3 < two.length; cnt3 ++)
				{
					arr.push(two.substr(cnt3, 1));
				}

				for(var cnt3 = 0; cnt3 < arr.length; cnt3 ++)
				{
					if (arr[cnt3] == "1")
					{
						arr[cnt3] = "2";
					}else if (arr[cnt3] == "2")
					{
						arr[cnt3] = "1";
					} 
				}

				var two2 = arr.join("");

				var nextPos = parseInt(two2, 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"));

