Solution for problem 67 based on problem 18