polycarp make quest friend he n task task boy evaluate interesting integer qi time ti minute need complete task an interesting feature quest participant task well suit depend preference the task choose base interactive quiz consist question the player answer question yes depend answer question participant move question go task quest in word quest binary tree node contain question leave contain task we know answer question ask get task take exactly minute quest player Polycarp know friend busy people can not participate quest t minute Polycarp wants choose n task invent correspond set question use form interactive quiz binary tree matter player answer quiz question spend T minute complete quest answer question complete task specifically quest contain zero question straight task each task ie people different answer question different taskspolycarp want total interest value task involve quest large possible help determine maximum possible total interest value task consider quest complete T minute variant answering question