solve problem D