Score : 1000 points
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the positions in the circle, starting from an arbitrary position and going around clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
You are given a string T=T_1T_2\cdots T_{|T|} such that T_i=S if the i-th song is a salsa and T_i=R if it is a rumba.
After all the songs have been played, the person that initially was in position i is in position P_i.
Compute the array P_0,P_1,\dots, P_{3^N-1}.
S and R.Input is given from Standard Input in the following format:
N T
You should print on Standard Output:
P_0 P_1 \cdots P_{3^N-1}
1 SRS
2 0 1
Before any song is played, the positions are: 0, 1, 2.
When we say "person i", we mean "the person that was initially in position i".
2 RRSRSSSSR
3 8 1 0 5 7 6 2 4
3 SRSRRSRRRSRRRR
23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10