Solution to problem 5