Tsunami

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

문제

Due to global warming and environmental crisis, we now need to make plans to survive for possible natural disasters. This time, we will make manuals for tsunamis.

The ocean line can be represented as a line parallel to the x-axis, y=ky=k. Normally kk would be 00, but when a tsunami occurs it will become a positive real number.

In our city, there will be NN evacuation spots represented as points (p_i,q_i)(p\_i, q\_i). At these spots, we will gather and move simultaneously. Also r_ir\_i is given for each spot, which denotes the time (in minutes) for you to go to that particular spot.

There will be obstacles to evacuation. For simplicity, we assume obstacles are straight-lined and parallel to the x-axis.

A total of MM obstacles are given as (s_i,e_i,y_i,t_i)(s\_i, e\_i, y\_i, t\_i), which are line segments connecting (s_i,y_i)(s\_i, y\_i) and (e_i,y_i)(e\_i, y\_i) that takes t_it\_i minutes to cross. Note that it also takes t_it\_i minutes crossing the obstacle even at the endpoints. No obstacles and evacuation spots coincide.

However obstacles themselves may overlap. In that case, the time crossing the overlapped obstacle is the sum of the overlapping t_it\_is. For example, if there are 2 obstacles (1,4,2,5)(1, 4, 2, 5) and (3,5,2,7)(3, 5, 2, 7), it will take 55 minutes to cross at x=1x=1, 5+7=125+7=12 minutes to cross at x=3x=3, 77 minutes to cross at x=5x=5.

We will only move upwards(i.e. +y direction) until we reach y=Yy=Y, which is the safe zone. While moving upwards, we can move our x-coordinates too. It takes c_ic\_i minutes per coordinate to move along the x-axis when our current y-coordinate is between ii and i+1i+1. For example when c_3=5c\_3=5 and we move our x-coordininate from 1010 to 66 at y=3.5y=3.5, it will take 5×106=205\times |10-6|=20 minutes.

We can only move to integer x-coordinates, and also can safely assume that we don't change x-coordinates at integer y-coordinates. Keep in mind that this is the only constraint. We can move to either x=100x=-100 or x=10100x=10^{100}, if you want.

Also note that c_1,...,c_Y1c\_1, ..., c\_{Y-1} is a nondecreasing sequence, since the number of people as yy increases will also increase, and therefore it will get harder to move between them.

The evacuation manual is as follows:

  • 1. We move to an appropriate evacuation spot.
  • 2. Starting from the spot, we move to y=Yy=Y under the given constraints.

We do not consider time moving simply upwards as it is nearly constant regardless of our starting evacuation spots. We only consider time moving to an evacuation spot, moving horizontally, and crossing obstacles.

Let's calculate the minimum possible time in minutes to evacuate to (1,Y)(1, Y), (2,Y)(2, Y), ..., (X,Y)(X, Y) respectively.

입력

The first line contains two space-separated integers XX and YY.

The second line contains two space-separated integers NN and MM.

Each of the following NN lines contain three space-separated integers p_ip\_i, q_iq\_i, r_ir\_i which denotes the iith evacuation spot.

Each of the following MM lines contain four space-separated integers s_is\_i, e_ie\_i, y_iy\_i, t_it\_i which denotes the iith obstacle.

The last line contains Y1Y-1 space-sperated integers c_1c\_1, c_2c\_2, ..., c_Y1c\_{Y-1}. c_ic\_i denotes the speed of changing the x-coordinate when your y-coordinate is between \[i,i+1]\[i, i+1].

출력

Print XX lines. In the iith line, print a single integer denoting the minimum time (in minutes) to reach point (i,Y)(i, Y).

제한

  • 3X,Y2×1053\leq X, Y\leq 2\times 10^5
  • 1N2×1051\leq N\leq 2\times 10^5
  • 0M2×1050\leq M\leq 2\times 10^5
  • 1p_iX1\leq p\_i\leq X, 1q_i\<Y1\leq q\_i\<Y, 0r_i10150\leq r\_i\leq 10^{15}
  • 1s_ie_iX1\leq s\_i\leq e\_i\leq X, 2y_i\<Y2\leq y\_i\<Y, 0t_i1090\leq t\_i\leq 10^9
  • 0c_1c_2...c_Y11060\leq c\_1\leq c\_2\leq ...\leq c\_{Y-1}\leq 10^6