In the Kingdom of IOI, the wind always blows from sea to land. There are spots numbered from
to
. The wind from Spot
to Spot
are in order. Mr. JOI has a house at Spot
. The altitude of Spot
is
, and the altitude of Spot
(
) is
.
The wind blows on the surface of the ground. The temperature of the wind changes according to the change in altitude. The temperature of the wind at Spot , which is closest to the sea, is
degrees. For each
(
), the change of the temperature of the wind from Spot
to Spot
depends only on the values of
and
in the following way:
- If
, the temperature of the wind decreases by
degrees per altitude.
- If
, the temperature of the wind increases by
degrees per altitude.
The tectonic movement is active in the land of the Kingdom of IOI. You have the data of tectonic movements for days. In the
-th (
) day, the change of the altitude of Spot
for
(
) is described by
. If
is not negative, the altitude increases by
. If
is negative, the altitude decreases by
.
Your task is to calculate the temperature of the wind at the house of Mr. JOI after each tectonic movement.
Given the data of tectonic movements, write a program which calculates, for each (
), the temperature of the wind at the house of Mr. JOI after the tectonic movement on the
-th day.
Input Specification
Read the following data from the standard input.
The first line of input contains four space separated integers
. This means there is a house of Mr. JOI at Spot
, there are
tectonic movements, the temperature of the wind decreases by
degrees per altitude if the altitude increases, and the temperature of the wind increases by
degrees per altitude if the altitude decreases.
The
-th line (
) of the following
lines contains an integer
, which is the initial altitude at Spot
before tectonic movements.
The
-th line (
) of the following
lines contains three space separated integers
. This means, for the tectonic movement on the
-th day, the change of the altitude at the spots from
to
is described by
.
Output Specification
Write lines to the standard output. The
-th line (
) of output contains the temperature of the wind at the house of Mr. JOI after the tectonic movement on the
-th day.
Constraints
All input data satisfy the following conditions.
.
.
.
.
.
.
.
.
Subtasks
Subtask 1 [30 points]
The following conditions are satisfied.
.
.
Subtask 2 [10 points]
.
Subtask 3 [60 points]
No additional constraints.
Sample Input 1
3 5 1 2
0
4
1
8
1 2 2
1 1 -2
2 3 5
1 2 -1
1 3 5
Sample Output 1
-5
-7
-13
-13
-18
Sample Input 2
2 2 5 5
0
6
-1
1 1 4
1 2 8
Sample Output 2
5
-35
Comments