After praying to the rating gods of Codeforces and Mr. DeMello, they have granted you the ability to view your future contest deltas.
For every contest, you can choose to either take or not take it, but these choices affect future contests.
Specifically, you can take the contest and travel to node
You are initially at node
A node represents the state of contests that you have taken in the past.
Since this is your rating, you decide to find the maximum rating you can achieve after you have made a choice for each contest.
Can you help yourself?
Input Specification
The first line will contain
The next
Note: The data guarantee that the connections cannot return to an earlier contest and form a directed tree.
Output Specification
Output the maximum rating achievable.
Sample Input
3 1500
1 2 3 500
2 4 5 700
3 6 7 -500
4 8 9 100
5 10 11 50
6 12 13 1000
7 14 15 50
Sample Output
2800
Explanation for Sample Output
The maximum achievable rating is
Comments