Part 2 of #6 solution