Problem 1: complete solution.