solve problem 31