题目描述
Problem Description
In the year 9012, Z City's aviation base plans to host an aerobatics show. The performance area can be considered as a two-dimensional Cartesian coordinate system, where the horizontal coordinate represents the horizontal position and the vertical coordinate represents the flight altitude.
Initially, the $n$ aircraft will fly to the starting point $x = x_{st}$, where the altitude of the $i$-th aircraft at the starting point is $y_{i,0}$. Their target is the endpoint $x = x_{ed}$, where the altitude of the $i$-th aircraft should be $y_{i,1}$. Thus, each aircraft can be seen as a point in the coordinate system, with its flight path being a line segment from $(x_{st}, y_{i,0})$ to $(x_{ed}, y_{i,1})$, as shown in the figure below.

These $n$ aircraft start simultaneously and maintain a constant ground speed. Therefore, for any two intersecting flight paths (line segments), the corresponding two aircraft will inevitably reach the intersection point at the same time—this is when they perform their aerobatics. They will tilt their wings, showcasing the stunt of passing each other at extremely close distances, and then continue along their respective paths.
The aviation base has also recently developed a new stunt called "directional exchange." When two aircraft reach the intersection point, the one that was descending immediately switches to a climbing maneuver, while the one that was ascending performs a flip, passing each other belly-to-belly at extremely close distances, and then exchange their subsequent paths.
We do not need to concern ourselves with how the stunts are physically executed; the aircraft are still considered as points. Under both stunts, the changes in their paths are shown in the figure below ($y_{i,1}'$ represents the new altitude of the $i$-th aircraft at the endpoint after the exchange). It is easy to see that "directional exchange" turns their paths into折线, and maintains their relative order in altitude; while "passing each other" will change their relative order in altitude.

Now, the guest delegation has made a demanding request—at the endpoint $x = x_{ed}$, the relative order of the $n$ aircraft by altitude must be the same as at the starting point $x = x_{st}$. The delegation has also rated the "directional exchange" and "passing each other" stunts with difficulty coefficients $a$ and $b$, respectively. Each "directional exchange" stunt earns $a$ points, and each "passing each other" stunt earns $b$ points.
Additionally, there are $k$ members in the delegation, with the $i$-th member staying at position $(p_i, q_i)$ in a hot air balloon, having an observation range of $r_i$, capable of observing all stunts within the area $|x - p_i| + |y - p_i| \le r_i$.
If a stunt at an intersection point is observed by one or more guests, it can earn an additional $c$ points.
Note: Stunts, whether observed or not, can still earn $a$ or $b$ points.
The figure below shows a satisfying arrangement for the 4 flight paths and 4 intersections in the first figure of the problem description, including 2 "directional exchanges" and 2 "passing each other", with 3 stunts observed, earning $2a + 2b + 3c$ points. For easier observation, the intersections where "directional exchange" stunts occur are slightly separated.

In this scenario, you have become the planner for Z City's aviation base. You can decide whether to perform a "directional exchange" or "passing each other" at each intersection point. You are tasked with calculating the minimum and maximum possible scores for the entire aerobatics show, ensuring the delegation's requirements are met.
Input Format
The first line contains six non-negative integers $n, a, b, c, x_{st}, x_{ed}$, representing the total number of flight paths (segments), the score for "directional exchange" stunts, the score for "passing each other" stunts, the additional score for observed performances, the horizontal coordinate of the flight starting point, and the horizontal coordinate of the flight endpoint.
The second line contains $n$ non-negative integers $y_{i,0}$, where the $i$-th number represents the vertical coordinate of the starting point of the $i$-th flight path, given in ascending order, i.e., $y_{i,0} < y_{i+1,0}$.
The third line contains $n$ non-negative integers $y_{i,1}$, where the $i$-th number represents the vertical coordinate of the endpoint of the $i$-th flight path.
The fourth line contains a non-negative integer $k$, representing the number of guests.
The next $k$ lines each contain three non-negative integers $p_i, q_i, r_i$, representing the horizontal and vertical coordinates and the observation range of the $i$-th guest.
The input data also includes constraints on the total number of intersections between the flight paths (segments) on the lines $x = x_{st}$ and $x = x_{ed}$, detailed in the "Data Range and Hints".
Output Format
The output should be a single line containing two integers, representing the minimum and maximum possible scores for the entire aerobatics show, separated by a space.
Sample Input and Output
Input Sample #1
4 1 2 3 1 6
1 2 3 4
4 1 3 2
2
3 3 1
5 2 2
Output Sample #1
13 15
Input Sample #2
10 73 28 13 0 100
2 9 16 25 29 34 43 46 52 58
8 25 35 52 41 5 16 3 19 48
5
46 40 1
37 27 5
67 34 1
65 28 4
29 38 1
Output Sample #2
989 1619
Notes/Hints
Sample 1 Explanation
This sample's flight paths are the same as depicted in the figure in the problem description, except for the slightly different positions of the guests.
The lowest scoring performance plan is to perform "directional exchange" stunts at all intersection points, earning $4a + 3c = 13$ points.
The highest scoring performance plan is the same as depicted in the figure in the problem description, earning $2a + 2b + 3c = 15$ points.
Data Range
No three or more segments intersect at the same point.
All coordinates and $r_i$ are non-negative integers within $5 \times 10^7$.
$y_{i,0} < y_{i+1,0}$, and $y_{i,1}$ are distinct.
$x_{st} < p_i < x_{ed}, 1 ≤ a, b, c ≤ 10^3$.
| Test Case Number | $n, k$ Scale | Number of Intersections Scale | Constraints |
|---|---|---|---|
| 1 | $n, k \le 15$ | $\le 40$ | None |
| 2 | $n, k \le 15$ | $\le 40$ | None |
| 3 | $n, k \le 15$ | $\le 40$ | None |
| 4 | $n, k \le 15$ | $\le 40$ | None |
| 5 | $n \le 30,000, k \le 100$ | $\le 200,000$ | None |
| 6 | $n \le 30,000, k \le 100$ | $\le 200,000$ | None |
| 7 | $n \le 30,000, k \le 100$ | $\le 200,000$ | None |
| 8 | $n \le 30,000, k \le 100$ | $\le 200,000$ | None |
| 9 | $n, k \le 100,000$ | $\le 500,000$ | $a = b$ |
| 10 | $n, k \le 100,000$ | $\le 500,000$ | $a = b$ |
| 11 | $n, k \le 100,000$ | $\le 500,000$ | $a = b$ |
| 12 | $n, k \le 100,000$ | $\le 500,000$ | $a = b$ |
| 13 | $n, k \le 50,000$ | $\le 250,000$ | None |
| 14 | $n, k \le 50,000$ | $\le 250,000$ | None |
| 15 | $n, k \le 50,000$ | $\le 250,000$ | None |
| 16 | $n, k \le 50,000$ | $\le 250,000$ | None |
| 17 | $n, k \le 100,000$ | $\le 500,000$ | None |
| 18 | $n, k \le 100,000$ | $\le 500,000$ | None |
| 19 | $n, k \le 100,000$ | $\le 500,000$ | None |
| 20 | $n, k \le 100,000$ | $\le 500,000$ | None |
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分