How to solve the following problem?