Dinesh Goyal's submission of Tree Upshot | CodeChef