Jack The Lumberjack

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Jack the Lumberjack used to love chopping down trees. Jack is getting older and is becoming tired of this activity he used to love.  He thinks of an idea, 'The Big One' and fantasizes about going out into the forest one last time to harvest as many trees as possible.

Jack calls the forest administrator for his local evergreen forest. The forest administrator tells him about how the population changes for each species of tree. For each species kk, S_kS\_k trees are planted in year B_kB\_k. For the next Y_kY\_k years, the population increases by I_kI\_k per year. After Y_kY\_k years, it will decrease by the same amount I_kI\_k per year, until possibly dying out.

Armed with this information, Jack wants to figure out the maximum amount of trees that could be harvested at once from now until the future. If he is no longer around to do it, his descendants will be!

Assume all populations change instantly and at the same time, once per year. Jack would assess each population's size after the yearly change occurred.

입력

The input contains a single test case.  The first line contains an integer NN (1N1,0001 \le N \le 1\\,000) representing the number of tree species in the forest.

Each of the following NN lines represents a single tree species population. Each of these population lines contains 44 integer numbers Y I S B (0Y1,000,0000 \le Y \le 1\\,000\\,000, 0I1,0000 \le I \le 1\\,000, 0S1,000,0000 \le S \le 1\\,000\\,000, 0B1,000,0000 \le B \le 1\\,000\\,000). where SS is the starting population size, BB the year in which the population is planted, YY the number of years during which the population increases each year by II before it decreases by II until it (possibly) dies out.

출력

Print the maximum amount of trees that can be harvested in any single year.