Solution to problem 42