A double tourist path, located at a park in Ultima Thule, is working by the following principle:

  * We introduce the Cartesian coordinate system. 
  * At some points of time there are two tourists going (for a walk) from points ( - 1, 0) and (1, 0) simultaneously. The first one is walking from ( - 1, 0), the second one is walking from (1, 0). 
  * Both tourists in a pair move at the same speed 1 (distance unit per second), the first one moves along line x = - 1, the second one moves along line x = 1, both of them are moving in the positive direction of the Oy axis. 
  * At some points of time walls appear. Wall (li, ri) is a segment between points (0, li) and (0, ri). Each wall appears immediately. 



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.

Input

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.

Output

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.

Examples

Input

2 2
1 4 3
3 6 5
0 1


Output

2
4


Input

3 3
0 3 4
0 1 2
2 4 0
1 3 4


Output

2
4
4
#include <bits/stdc++.h>
using namespace std;
inline int get() {
  char c;
  while (!isdigit(c = getchar()))
    ;
  int v = c - 48;
  while (isdigit(c = getchar())) v = v * 10 + c - 48;
  return v;
}
int n, m, k, p, i, ll, lt, tt, o[400001], s[400001], v[400001];
map<int, int> Mp;
struct Ar {
  int l;
  bool i;
  const bool operator<(const Ar &h) const {
    return (l << 1) - i < (h.l << 1) - h.i;
  };
} ar[400001];
struct El : Ar {
  int t;
} el[100001 << 1];
int main() {
  m = get();
  n = get();
  for (i = 0; i < n; i++) {
    el[i + i].l = get();
    el[i + i + 1].l = get();
    el[i + i].t = el[i + i + 1].t = get();
    el[i + i].i = 1;
  }
  sort(el, el + n + n);
  lt = (1 << 30);
  Mp[(1 << 30)] = 1;
  for (i = 0; i < n + n; i++) {
    if (el[i].i)
      Mp[el[i].t]++;
    else if ((--Mp[el[i].t]) == 0)
      Mp.erase(el[i].t);
    if ((tt = Mp.begin()->first) != lt && lt != (1 << 30)) {
      ar[k].l = ll - lt;
      ar[k++].i = 1;
      ar[k++].l = (ll = el[i].l) - lt;
    } else if (lt == (1 << 30))
      ll = el[i].l;
    lt = tt;
  }
  sort(ar, ar + k);
  o[0] = 1;
  v[0] = ar[0].l;
  for (i = 1; i < k; i++) {
    v[i] = ar[i].l;
    o[i] = o[i - 1] + (ar[i].i ? 1 : -1);
    s[i] = s[i - 1] + o[i - 1] * (ar[i].l - ar[i - 1].l);
  }
  for (i = 1; i <= m; i++) {
    if ((tt = upper_bound(v, v + k, p = -get()) - v - 1) < 0) {
      printf("%d\n", s[k - 1]);
      continue;
    }
    printf("%d\n", s[k - 1] - s[tt] - o[tt] * (p - v[tt]));
  }
  return 0;
}
