There are squirrels sitting on a line. The squirrel with number is located at the point with integer coordinate x_i, where x_1 < x_2 < \dots < x_n. The squirrels do not move.
You have an umbrella of length . If its left end is at point , then it protects all squirrels whose coordinates belong to the segment [p, p + w].
The umbrella must always be completely between the first and the last squirrel, that is, x_1 \leq p and p + w \leq x_n.
At time , you may freely choose any valid position of the umbrella. For each subsequent unit of time, you may move it one coordinate unit to the left, one coordinate unit to the right, or leave it in place.
There are nut falls. The -th fall is described by three integers t_j, l_j, and r_j: at time t_j, nuts fall on all squirrels whose coordinates belong to the segment [l_j, r_j].
If a squirrel is not under the umbrella during a fall, it gets injured. A squirrel is considered saved if it is not injured during any fall. Squirrels on which nuts never fall are also considered saved.
At each integer moment of time, first the movement of the umbrella during the previous unit of time finishes, and then all falls scheduled for that moment occur.
If several falls have the same time, they occur simultaneously, so the umbrella cannot be moved between them.
Find the maximum number of squirrels that can be saved.
The first line contains three integers , , and (2 \leq n \leq 44, 1 \leq q \leq 2 \cdot 10^5) — the number of squirrels, the number of nut falls, and the length of the umbrella.
The second line contains integers x_1, x_2, \dots, x_n (0 \leq x_1 < x_2 < \dots < x_n \leq 10^9) — the coordinates of the squirrels.
It is guaranteed that 1 \leq w \leq x_n - x_1.
Each of the next lines contains three integers t_j, l_j, and r_j (1 \leq t_j \leq 10^9, 0 \leq l_j \leq r_j \leq 10^9) — the time of the fall and the boundaries of the segment on which nuts fall.
The falls are given in arbitrary order. Times of different falls may coincide.
Print one integer — the maximum number of squirrels that can be saved.
Example 1
Example 2
Example 3
In the first example, nuts fall on the squirrels at points , , and . An umbrella of length can protect at most two of them at the same time, for example the squirrels at points and . The squirrels at points and are not affected by any fall, so they are also saved. Therefore, the maximum number of saved squirrels is .
In the second example, all three falls happen simultaneously. Nuts fall on the squirrels at points , , and . An umbrella of length can protect only one of them. The squirrels at points and are not affected by any fall, so the maximum number of saved squirrels is .
In the third example, at time the umbrella can be positioned so as to protect the squirrel at point . By time , there is enough time to move the umbrella and protect the squirrel at point . Therefore, all squirrels can be saved.
Subtask ( points): q = 1.
Subtask ( points): all values t_j are equal.
Subtask ( points): n \le 10, q \le 20, x_n \le 20, t_j \le 20.
Subtask ( points): n \le 20, q \le 2000.
Subtask ( points): n \le 20.
Subtask ( points): q \le 2000.
Subtask ( points): No additional constraints.