In the Kingdom of IOI, the wind always blows from sea to land. There are
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
- 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
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
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
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