Problem: <image>

It is well-known that the best decoration for a flower bed in Sweetland are vanilla muffins. Seedlings of this plant need sun to grow up. Slastyona has m seedlings, and the j-th seedling needs at least kj minutes of sunlight to grow up.

Most of the time it's sunny in Sweetland, but sometimes some caramel clouds come, the i-th of which will appear at time moment (minute) li and disappear at time moment ri. Of course, the clouds make shadows, and the seedlings can't grow when there is at least one cloud veiling the sun.

Slastyona wants to grow up her muffins as fast as possible. She has exactly C candies, which is the main currency in Sweetland. 

One can dispel any cloud by paying ci candies. However, in order to comply with Sweetland's Department of Meteorology regulations, one can't dispel more than two clouds.

Slastyona hasn't decided yet which of the m seedlings will be planted at the princess' garden, so she needs your help. For each seedling determine the earliest moment it can grow up if Slastyona won't break the law and won't spend more candies than she has. Note that each of the seedlings is considered independently.

The seedlings start to grow at time moment 0.

Input

The first line contains two integers n and C (0 ≤ n ≤ 3·105, 0 ≤ C ≤ 109) – the number of caramel clouds and the number of candies Slastyona has.

The next n lines contain three integers each: li, ri, ci (0 ≤ li < ri ≤ 109, 0 ≤ ci ≤ 109), describing one caramel cloud.

The next line contains single integer m (1 ≤ m ≤ 3·105) – the number of seedlings. Each of the seedlings is described with one integer kj (1 ≤ kj ≤ 109) – the required number of sunny minutes.

Output

For each seedling print one integer – the minimum minute Slastyona can grow it up.

Examples

Input

3 5
1 7 1
1 6 2
1 7 1
3
7
2
5


Output

12
7
10


Input

3 15
1 4 17
2 8 6
4 8 9
2
5
1


Output

8
1


Input

2 10
3 7 9
10 90 10
2
10
100


Output

10
104

Note

Consider the first example. For each k it is optimal to dispel clouds 1 and 3. Then the remaining cloud will give shadow on time segment [1..6]. So, intervals [0..1] and [6..inf) are sunny.

<image>

In the second example for k = 1 it is not necessary to dispel anything, and for k = 5 the best strategy is to dispel clouds 2 and 3. This adds an additional sunny segment [4..8], which together with [0..1] allows to grow up the muffin at the eight minute.

<image> <image>

If the third example the two seedlings are completely different. For the first one it is necessary to dispel cloud 1 and obtain a sunny segment [0..10]. However, the same strategy gives answer 180 for the second seedling. Instead, we can dispel cloud 2, to make segments [0..3] and [7..inf) sunny, and this allows up to shorten the time to 104.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 300000;
const int MAXNEED = 1000000000;
typedef struct S {
  int l, r, cnt, id;
} S;
typedef struct Z {
  int pref, l, cnt;
} Z;
int n, budget;
int lx[MAXN], rx[MAXN], scost[MAXN];
int last[2 * MAXN];
pair<int, int> e[2 * MAXN];
int ne;
pair<int, int> p[MAXN];
int np;
S s[2 * MAXN + 1];
int ns;
set<int> active;
int have[2 * MAXN];
int bestother[MAXN];
map<int, int> one;
int best;
Z a[2 * MAXN + 1];
int na;
Z b[2 * MAXN + 1];
int nb;
int getone(int rem) {
  auto it = one.lower_bound(rem);
  if (it == one.end() || it->first > rem) --it;
  return it->second;
}
void updone(int key, int val) {
  auto it = one.lower_bound(key);
  if (it == one.end() || it->first > key) --it;
  if (it->second >= val) return;
  while (true) {
    auto nx = it;
    ++nx;
    if (nx == one.end() || nx->second > val) break;
    one.erase(nx);
  }
  one[key] = val;
}
int solve(Z *c, int nc, int q) {
  int l = -1, r = nc - 1;
  while (l + 1 < r) {
    int m = l + (r - l) / 2;
    if (c[m].pref + c[m].cnt >= q)
      r = m;
    else
      l = m;
  }
  return c[r].l + q - c[r].pref;
}
void run() {
  scanf("%d%d", &n, &budget);
  for (int i = (0); i < (n); ++i) scanf("%d%d%d", &lx[i], &rx[i], &scost[i]);
  ne = 0;
  for (int i = (0); i < (n); ++i)
    e[ne++] = make_pair(lx[i], 2 * i + 0),
    e[ne++] = make_pair(rx[i], 2 * i + 1);
  sort(e, e + ne);
  ns = 0;
  np = 0;
  active.clear();
  for (int i = (0); i < (n); ++i) last[i] = -1;
  for (int at = 0, to = at; at < ne; at = to) {
    while (to < ne && e[at].first == e[to].first) ++to;
    s[ns].l = (ns == 0 ? 0 : s[ns - 1].r), s[ns].r = e[at].first,
    s[ns].cnt = ((int)(active).size()), s[ns].id = -1;
    if (((int)(active).size()) == 1) {
      s[ns].id = *active.begin();
      last[s[ns].id] = ns;
    }
    if (((int)(active).size()) == 2) {
      int u = *active.begin(), v = *next(active.begin());
      if (u > v) swap(u, v);
      if (np == 0 || make_pair(u, v) != p[np - 1])
        p[np] = make_pair(u, v), ++np;
      s[ns].id = n + np - 1;
      last[s[ns].id] = ns;
    }
    ++ns;
    for (int i = (at); i < (to); ++i)
      if (e[i].second % 2 == 0)
        active.insert(e[i].second / 2);
      else
        active.erase(e[i].second / 2);
  }
  s[ns].l = (ns == 0 ? 0 : s[ns - 1].r), s[ns].r = s[ns].l + MAXNEED,
  s[ns].cnt = 0, s[ns].id = -1, ++ns;
  for (int i = (0); i < (n + np); ++i) have[i] = 0;
  na = 0;
  one.clear();
  one[0] = 0;
  best = 0;
  for (int i = (0); i < (ns); ++i) {
    if (s[i].cnt == 0) {
      a[na].pref = (na == 0 ? 0 : a[na - 1].pref + a[na - 1].cnt),
      a[na].l = s[i].l, a[na].cnt = s[i].r - s[i].l, ++na;
    }
    if (s[i].cnt == 1 && scost[s[i].id] <= budget) {
      int cur = have[s[i].id] + getone(budget - scost[s[i].id]),
          len = s[i].r - s[i].l, need = best - cur;
      if (len > need) {
        a[na].pref = (na == 0 ? 0 : a[na - 1].pref + a[na - 1].cnt),
        a[na].l = s[i].l + need, a[na].cnt = len - need, ++na;
        best += len - need;
      }
      have[s[i].id] += len;
      if (i == last[s[i].id]) updone(scost[s[i].id], have[s[i].id]);
    }
  }
  for (int i = (0); i < (n + np); ++i) have[i] = 0;
  for (int i = (0); i < (n); ++i) bestother[i] = 0;
  nb = 0;
  best = 0;
  for (int i = (0); i < (ns); ++i) {
    if (s[i].cnt == 0) {
      b[nb].pref = (nb == 0 ? 0 : b[nb - 1].pref + b[nb - 1].cnt),
      b[nb].l = s[i].l, b[nb].cnt = s[i].r - s[i].l, ++nb;
    }
    if (s[i].cnt == 1 && scost[s[i].id] <= budget) {
      int cur = have[s[i].id] + bestother[s[i].id], len = s[i].r - s[i].l,
          need = best - cur;
      if (len > need) {
        b[nb].pref = (nb == 0 ? 0 : b[nb - 1].pref + b[nb - 1].cnt),
        b[nb].l = s[i].l + need, b[nb].cnt = len - need, ++nb;
        best += len - need;
      }
      have[s[i].id] += len;
    }
    if (s[i].cnt == 2 &&
        scost[p[s[i].id - n].first] + scost[p[s[i].id - n].second] <= budget) {
      int u = p[s[i].id - n].first, v = p[s[i].id - n].second,
          cur = have[u] + have[v] + have[s[i].id], len = s[i].r - s[i].l,
          need = best - cur;
      if (len > need) {
        b[nb].pref = (nb == 0 ? 0 : b[nb - 1].pref + b[nb - 1].cnt),
        b[nb].l = s[i].l + need, b[nb].cnt = len - need, ++nb;
        best += len - need;
      }
      have[s[i].id] += len;
      if (have[v] + have[s[i].id] > bestother[u])
        bestother[u] = have[v] + have[s[i].id];
      if (have[u] + have[s[i].id] > bestother[v])
        bestother[v] = have[u] + have[s[i].id];
    }
  }
  int nq;
  scanf("%d", &nq);
  for (int i = (0); i < (nq); ++i) {
    int q;
    scanf("%d", &q);
    int ares = solve(a, na, q);
    int bres = solve(b, nb, q);
    int res = min(ares, bres);
    printf("%d\n", res);
  }
}
int main() {
  run();
  return 0;
}