n = int(input())
step = 0
def move(n, fro, to):
global step
step += 1
print("Move " + str(n) + " from " + fro + " to " + to)
def hanota(n, a, b, c):
step = 0
if n == 1:
move(n, a, b)
move(n, b, c)
else:
hanota(n - 1, a, b, c)
move(n, a, b)
hanota(n - 1, c, b, a)
move(n, b, c)
hanota(n - 1, a, b, c)
hanota(n, "left", "mid", "right")
print("It will move " + str(step) + " steps.")