Third problem

partial implementation.