input: Write a function to solve the Towers of Hanoi game. The function should take the number of disks (n) and the source, spare, and target pegs as inputs. It should print the moves required to transfer all disks from the source peg to the target peg. If there's only one disk, it should directly move it from source to target. Otherwise, it should recursively move the top n-1 disks to the spare peg, 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(1, [(1, "A")], [], [])
  assert hanoi(2, [(1, "A"), (2, "A")], [], [])
  assert hanoi(3, [(1, "A"), (2, "A"), (3, "A")], [], [])
  assert hanoi(4, [(1, "A"), (2, "A"), (3, "A"), (4, "A")], [], [])
  assert hanoi(5, [(1, "A"), (2, "A"), (3, "A"), (4, "A"), (5, "A")], [], [])
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)