Solution for problem 38