#1976. 汉诺塔问题

汉诺塔问题

Explanation

At the end of the 1919th century, a type of intellectual toy was sold in stores in Europe. It had three poles on a copper plate, with a tower consisting of 6464 disks strung from top to bottom and from small to large on the leftmost pole. The purpose is to move all the plates on the leftmost pole to the middle pole, provided that only one plate can be moved at a time and the large plate is not allowed to be placed on top of the small plate. This is a famous question that almost all textbooks have. Due to the condition that only one plate can be moved at a time and the large plate is not allowed to be placed on top of the small plate, the number of moves per plate of 6464 is 18446744073095516151844674407309551615. This is an astronomical number, and if it is possible to calculate (without outputting) one movement per microsecond, it would take almost one million years. We can only find a solution to the problem and solve the Hanno Tower with small NN values, but it is difficult to solve the Hanno Tower at the 6464 level with a computer. Assuming that the disks are numbered from small to large as 1,2..1, 2 ..

Input format

Input as an integer N(N<20)N (N<20) followed by three single character strings. The integer represents the number of plates, and the last three characters indicate the numbering of the three poles.

Output format

Output a record of each step of moving the plate. Move one line at a time. The record of each movement is in the form of, for example, a ->3->b, which means that the plate with the number 3 is moved from pole a to pole b.

Example

2 a b c
a->1->c
a->2->b
c->1->b