input: Write a function to solve the Towers of Hanoi game. The function should take in the number of disks n and three lists representing the source, spare, and target pegs. The function should print the moves required to transfer all disks from the source peg to the target peg, following the rules of the game. If n is 1, simply move the disk from the source to the target. Otherwise, first move the top n-1 disks from the source to the spare, then move the nth disk from the source to the target, and finally move the n-1 disks from the spare to the target.
  
  
  def hanoi(n, source, spare, target):
      if n == 1:
          disk = source.pop(0)
          print("Moving disk {} from {} to {}".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 {} from {} to {}".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)
  
  
  assert hanoi(3, [(i, "A") for i in range(1, 4)], [], [])
output: def hanoi(n, source, spare, target):
      if n == 1:
          disk = source.pop(0)
          print("Moving disk {} from {} to {}".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 {} from {} to {}".format(disk[0], disk[1], target[1]))
          target.insert(0, disk)
          hanoi(n-1, spare, source, target)