Implement problem 4.