Solution to the problem