input: 
  def hanoi(n, source, spare, target):
      """Solve the Towers of Hanoi game by moving 'n' disks from the 'source' peg to the 'target' peg,
      using the 'spare' peg as an intermediary.
      >>> starting = [(1, "A"), (4, "A"), (7, "A"), (2, "A"), (5, "A"), (8, "A"), (3, "A"), (6, "A")]
      >>> n = 8
      >>> source = starting
      >>> target = []
      >>> spare = []
      >>> hanoi(n, source, spare, target)
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 3 from A to B
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      Moving disk 4 from A to C
      Moving disk 1 from B to C
      Moving disk 2 from B to A
      Moving disk 1 from C to A
      Moving disk 3 from B to C
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 5 from A to B
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      Moving disk 3 from C to A
      Moving disk 1 from B to C
      Moving disk 2 from B to A
      Moving disk 1 from C to A
      Moving disk 4 from C to B
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 3 from A to B
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      Moving disk 6 from A to C
      Moving disk 1 from B to C
      Moving disk 2 from B to A
      Moving disk 1 from C to A
      Moving disk 3 from B to C
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 4 from B to A
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      Moving disk 3 from C to A
      Moving disk 1 from B to C
      Moving disk 2 from B to A
      Moving disk 1 from C to A
      Moving disk 5 from B to C
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 3 from A to B
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      Moving disk 4 from A to C
      Moving disk 1 from B to C
      Moving disk 2 from B to A
      Moving disk 1 from C to A
      Moving disk 3 from B to C
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 7 from A to B
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      Moving disk 3 from C to A
      Moving disk 1 from B to C
      Moving disk 2 from B to A
      Moving disk 1 from C to A
      Moving disk 4 from C to B
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 3 from A to B
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      Moving disk 5 from C to A
      Moving disk 1 from B to C
      Moving disk 2 from B to A
      Moving disk 1 from C to A
      Moving disk 3 from B to C
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 4 from B to A
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      Moving disk 3 from C to A
      Moving disk 1 from B to C
      Moving disk 2 from B to A
      Moving disk 1 from C to A
      Moving disk 6 from C to B
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 3 from A to B
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      Moving disk 4 from A to C
      Moving disk 1 from B to C
      Moving disk 2 from B to A
      Moving disk 1 from C to A
      Moving disk 3 from B to C
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 5 from A to B
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      Moving disk 3 from C to A
      Moving disk 1 from B to C
      Moving disk 2 from B to A
      Moving disk 1 from C to A
      Moving disk 4 from C to B
      Moving disk 1 from A to B
      Moving disk 2 from A to C
      Moving disk 1 from B to C
      Moving disk 3 from A to B
      Moving disk 1 from C to A
      Moving disk 2 from C to B
      Moving disk 1 from A to B
      """
      if n == 1:
          disk = source.pop(0)
          print("Moving disk {0} from {1} to {2}".format(disk[0], disk[1], target[1]))
          target.insert(0, disk)
      else:
          hanoi(n-1, source, target, spare)
          disk = source.pop(0)
          print("Moving disk {0} from {1} to {2}".format(disk[0], disk[1], target[1]))
          target.insert(0, disk)
          hanoi(n-1, spare, source, target)
  
  n = 8
  source = [(i, "A") for i in range(1, n+1)]
  target = []
  spare = []
  
  hanoi(n, source, spare, target)
  
output:     
      if n == 1:
          disk = source.pop(0)
          print("Moving disk {0} from {1} to {2}".format(disk[0], disk[1], target[1]))
          target.insert(0, disk)
      else:
          hanoi(n-1, source, target, spare)
          disk = source.pop(0)
          print("Moving disk {0} from {1} to {2}".format(disk[0], disk[1], target[1]))
          target.insert(0, disk)
          hanoi(n-1, spare, source, target)
  