Kingdom and its Cities

CodeForces - 613D