input: Write a function to implement the Towers of Hanoi game. The function should take the number of disks, the source peg, the spare peg, and the target peg as arguments. It should recursively move the disks from the source peg to the target peg, following the rules of the game. If there is only one disk, it should be moved directly to the target peg. If there are more than one disk, it should first move n-1 disks to the spare peg, then move the nth disk to the target peg, and finally move the n-1 disks from the spare peg to the target peg.
  
  assert hanoi(8, [(i, "A") for i in range(1, 9)], [], [])
  assert hanoi(3, [(i, "A") for i in range(1, 4)], [], [])
  assert hanoi(1, [(1, "A")], [], [])
  assert hanoi(0, [], [], [])
  assert hanoi(5, [(i, "A") for i in range(1, 6)], [], [])
output: def hanoi(n, source, spare, target):
      if n == 1:
          target.append(source.pop())
      else:
          hanoi(n-1, source, target, spare)
          target.append(source.pop())
          hanoi(n-1, spare, source, target)