Hemose on the Tree

CodeForces - 1670E