import java.util.*;

/***
Recursive definition of towers of hanoi
	to move a single disc from 'source' to 'dest' using 'aux' as auxiliary: simply move the disc from 'source' to 'dest'
	to move a n discs from 'source' to 'dest' using 'aux' as auxiliary: 
		move n-1 discs from 'source' to 'aux' using 'dest' as auxiliary
		move disc n from 'source' to 'dest'
		move n-1 discs from 'aux' to 'dest' using 'source' as auxiliary
***/

public class Towers {
	public static void main(String [] args) {
		Scanner keyboard = new Scanner(System.in);

		System.out.print("How many rings? ");
		int n = keyboard.nextInt();

		towers(n, 'A', 'B', 'C');
	}

	static void towers(int n, char source, char aux, char dest) {
		if (n == 1) 
			System.out.println("*** Move disc 1 from " + source + " to " + dest);
		else {
			towers(n-1, source, dest, aux);
			System.out.println("*** Move disc " + n + " from " + source + " to " + dest);
			towers(n-1, aux, source, dest);
		}
	}
} 
