import string

alg = "R' D R"

state = solved = "UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR".split()
for move in alg.split():
    perm = "FLBR FRBL FDBU FUBD URDL ULDR".split()['UDLRFB'.index(move[0])]
    n = len(move) + move.endswith("'")
    table = string.maketrans(perm, perm[n:] + perm[:n])
    state = [p.translate(table) if move[0] in p else p for p in state]
for io in zip(solved, state):
    if io[0] != io[1]:
        print "{} moved to {}".format(*io)