# Hanoi Towers

Time Limit: 5000MS

Memory Limit: 65536K

## Description

The “Hanoi Towers” puzzle consists of three pegs (that we will name A, B, and C) with n disks of different diameters stacked onto the pegs. Initially all disks are stacked onto peg A with the smallest disk at the top and the largest one at the bottom, so that they form a conical shape on peg A.

## Input

The input file contains two lines. The first line consists of a single integer number n (1 ≤ n ≤ 30) — the number of disks in the puzzle. The second line contains descriptions of six moves separated by spaces — the strategy that is used to solve the puzzle.

## Output

Write to the output file the number of moves it takes to solve the puzzle. This number will not exceed 1018.

## Sample Input

#13AB BC CA BA CB AC#22AB BA CA BC CB AC

## Sample Output

#17#25

N/A