Preparando MOJI
A double tourist path, located at a park in Ultima Thule, is working by the following principle:
The Ultima Thule government wants to learn this for each pair of tourists that walk simultaneously: for how long (in seconds) will they not see each other? Two tourists don't see each other if the segment that connects their positions on the plane intersects at least one wall. Two segments intersect if they share at least one point. We assume that the segments' ends belong to the segments.
Help the government count the required time. Note that the walls can intersect (in any way) or coincide.
The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 105) — the number of pairs of tourists and the number of built walls. The next m lines contain three space-separated integers li, ri and ti each (0 ≤ li < ri ≤ 109, 0 ≤ ti ≤ 109) — the wall ends and the time it appeared. The last line contains n distinct space-separated strictly increasing integers q1, q2, ..., qn (0 ≤ qi ≤ 109) — the points of time when pairs of tourists walk.
All points of time are given in seconds.
For each pair of tourists print on a single line a single integer — the time in seconds when the two tourists from the corresponding pair won't see each other. Print the numbers in the order in which the they go in the input.
2 2
1 4 3
3 6 5
0 1
2
4
3 3
0 3 4
0 1 2
2 4 0
1 3 4
2
4
4