Solution for problem 31.