Tower Of Hanoi

easy
1.You are given the number of discs N and three rods 1,2 and 3.
 2.Initially, these discs are in the rod 1.
 3.You need to print all the steps of discs movement so that all the discs reach the 3rd rod.You can use rod 2 also.
 Note: The discs are arranged such that the top disc is numbered 1 and the bottom-most disc is numbered N. Also, all the discs have different sizes and a bigger disc cannot be put on the top of a smaller disc.

Input Format

First line contains an Integer 'N'.

Output Format

Print the moves required to move the entire stack from rod 1 to rod 2.

Constraints

1<=N<=16

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
3
Output
Move disk 1 from rod 1 to rod 3
Move disk 2 from rod 1 to rod 2
Move disk 1 from rod 3 to rod 2
Move disk 3 from rod 1 to rod 3
Move disk 1 from rod 2 to rod 1
Move disk 2 from rod 2 to rod 3
Move disk 1 from rod 1 to rod 3
Next
Print Decreasing

Related Questions