Ohani was tired of sitting in a mall, watching people hold hands. He hates public displays of affection (PDA). So, he decided to take a walk. He was walking through a magical forest when he came across a porcupine. He noticed that the porcupine's body was completely made of gold. The porcupine said:
Over a period of
seconds, I will shoot
quills out in total. The
quill exists only between the
and
seconds (inclusive).
The height of the
can be expressed as
, where
,
, and
are constants for the
quill and
is the number of seconds the quill has been in the air. For the
quill, at time
,
.
These quills have magical gravity and pass through anything, so it's perfectly fine for
to be more than
or the height of a quill to be less than
at any point in time.
Can you tell me the sum of the heights of all the quills at each second in time between
and
inclusive?
Ohani was able to solve the problem and get home just in time to play with legos with his brother. Ohani loves legos, and his brother is a lego lover too.
Input Specification
The first line will contain two integers,
.
The next
lines will each contain five integers,
.
Output Specification
Print
integers on one line, the
integer representing the sum of heights of quills at the
second in time.
Constraints
Subtask 1 [1%]

Subtask 2 [4%]

Subtask 3 [5%]

Subtask 4 [20%]

Subtask 5 [70%]
No additional constraints.
Sample Input
Copy
2 6
1 6 1 3 2
3 4 2 2 -200
Sample Output
Copy
2 6 -188 -176 30 42
Explanation of Sample Output
The first quill's trajectory is shown as follows:
The second quill's trajectory is shown as follows:
At the
second, the sum of the heights is only quill
at
as quill
does not exist yet
.
At the
second, the sum of the heights is only quill
at
as quill
does not exist yet
.
At the
second, the sum of the heights is quill
at
and quill
at
.
At the
second, the sum of the heights is quill
at
and quill
at
.
At the
second, the sum of the heights is only quill
at
as quill
no longer exists
.
At the
second, the sum of the heights is only quill
at
as quill
no longer exists
.
Comments
nice problem