def r(l,n):
    return list(map(lambda a: (a+n)%len(l), l))
def s(l,m):
    return list(map(lambda a: m[a],l))
if __name__ == '__main__':
    n = input()
    m = list(range(0, 3**int(n)))
    for i in m:
        res = 0
        temp = 1
        record = i
        while i != 0:
            if i % 3 == 1:
                res += 2*temp
            elif i % 3 == 2:
                res += 1*temp
            temp *= 3
            i //= 3
        m[record] = res

    l = list(range(0, 3**int(n)))
    cmd = list(input())
    j = 0
    new_cmd = []
    while j < len(cmd):
        temp = 0
        while  j < len(cmd) and cmd[j] == "S":
            j += 1
            temp += 1
        if temp % 2 == 1:
            new_cmd.append("S")
        temp = 0
        while j < len(cmd) and cmd[j] == "R":
            j += 1
            temp += 1
        new_cmd.append("R" * temp)
    for c in new_cmd:
        if c == "S":
           l = s(l,m)
        else:
            l = r(l,len(c))
    for p in l:
        print(p, end=" ")


