Mashmokh play new game in begin k liter water p coin additionally root tree undirecte connect acyclic graph consist m vertex each vertex tree contain water tank beginningthe game begin fact Mashmokh choose k tank root pour exactly 1 liter water then follow process perform water remained tank the process consist step at begin step Mashmokh open door tank then Mashmokh close door tank allow close door tank root duration Lets denote number liter tank close door w Mashmokh pay w coin closing tank Lets denote x1x2xm list vertex tree sort nondecrease depth the vertex list consider order firstly vertex x1 root empty then vertex xi i1 door close skip vertex water tank vertex xi tank father tank father close suppose l move tree Lets denote water inside tank root ith wi Mashmokh win maxw1w2wl dollar Mashmokh want know maximum dollar win playing game he ask find value