output_description: You should print on Standard Output:
  
      
      
      P_0 P_1 \cdots P_{3^N-1}
      
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      T
attempt: # salsa=0, rumba=1
  # [0 1 0 1] 1より上の位に帯する操作
  
  # 繰り上がりを考慮しつつ、3（より上）の位に対する操作を考える
  # [1]       1の位が0である数字の、3の位に対する操作
  # [0 1 0]   1の位が1である数字の、3の位に対する操作
  # []        1の位が2である数字の、3の位に対する操作
  # ある数字が"2"の時にルンバが来れば繰り上がる（上の位にルンバが波及）
  # それ以外の状態では、上の位にとってルンバは無いのと同じことになる
  # サルサは常に影響するが、連続した2つのサルサは打ち消し合い、無いのと同じことになる
  
  # 再帰的に上の位を決める
  # []        3,1の位が00,10である数字の、9の位に対する操作
  # [1]       3,1の位が20である数字の、9の位に対する操作
  # []        3,1の位が01,21である数字の、9の位に対する操作
  # [0 1 0]   3,1の位が11である数字の、9の位に対する操作
  # []        3,1の位が02,12,22である数字の、9の位に対する操作
  
  # 一度繰り上がったら、例えば100.. と0がd個続くとして、
  # 更にその上の位に波及させるには 2^d オーダーの操作が必要となるので、各操作列は徐々に減っていく
  
  n = int(input())
  t = input()
  op = [[int(c == "R") for c in t]]
  ans = [0]
  
  for d in range(n):
      k = 3**d
      nop = []
      nans = [0] * (k * 3)
      for g in range(3):  # d桁目の数
          for i in range(k):  # d桁目未満の数
              opg = op[i]
              opn = []
              h = g
              for o in opg:
                  if o == 0:
                      if len(opn) > 0 and opn[-1] == 0:
                          opn.pop()
                      else:
                          opn.append(0)
                      if h == 1:
                          h = 2
                      elif h == 2:
                          h = 1
                  else:
                      if h == 2:
                          h = 0
                          opn.append(1)
                      else:
                          h += 1
              nop.append(opn)
              nans[g * k + i] = h * k + ans[i]
  
      op = nop
      ans = nans
  
  print(*ans)
  
problem_description: Statement
  
  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.
  
    * When a salsa is played, the person in position i goes to position j, where j is the number obtained replacing all digits 1 with 2 and all digits 2 with 1 when reading i in base 3 (e.g., the person in position 46 goes to position 65).
    * When a rumba is played, the person in position i moves to position i+1 (with the identification 3^N = 0).
  
  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}.
samples: [{"input": "1\n    SRS", "output": "2 0 1 \n    \n\nBefore any song is played, the positions are: 0, 1, 2.\n\nWhen we say \"person i\", we mean \"the person that was initially in position i\".\n\n  1. After the first salsa, the positions are: 0, 2, 1.\n  2. After the rumba, the positions are: 1, 0, 2 (so, person 0 is in position 1, person 1 is in position 0 and person 2 is in position 2).\n  3. After the second salsa, the positions are 2, 0, 1 (so, person 0 is in position 2, person 1 is in position 0 and person 2 is in position 1).\n\n* * *"}, {"input": "2\n    RRSRSSSSR", "output": "3 8 1 0 5 7 6 2 4 \n    \n\n* * *"}, {"input": "3\n    SRSRRSRRRSRRRR", "output": "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"}]