Solution to problem 2