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>
template <class T>
inline void read(T &x) {
  x = 0;
  register char c = getchar();
  register bool f = 0;
  while (!isdigit(c)) f ^= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  if (f) x = -x;
}
template <class T>
inline void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 3e5 + 10;
int n, m, s, f[N], sa[N], rk[N], pt[N], ans[N];
struct node {
  int l, r, w;
} a[N];
std::set<int> set;
std::vector<int> val, G[N], L[N], ins[N << 1], del[N << 1];
std::map<int, int> map[N];
std::pair<int, int> seg[N << 2];
std::multiset<int> g[N];
std::vector<std::pair<int, int>> qry, edg;
std::vector<std::pair<std::pair<int, int>, int>> q;
std::pair<int, int> merge(const std::pair<int, int> &a,
                          const std::pair<int, int> &b) {
  if (a.first > b.first) {
    return {a.first, std::max(a.second, b.first)};
  } else {
    return {b.first, std::max(a.first, b.second)};
  }
}
void modify(int u, int k, int x, int l, int r) {
  if (l == r) {
    seg[u] = {x, 0};
    return;
  }
  int mid = (l + r) >> 1;
  if (k <= mid)
    modify(u << 1, k, x, l, mid);
  else
    modify(u << 1 | 1, k, x, mid + 1, r);
  seg[u] = merge(seg[u << 1], seg[u << 1 | 1]);
}
std::pair<int, int> query(int u, int ql, int qr, int l, int r) {
  if (ql == l && qr == r) return seg[u];
  int mid = (l + r) >> 1;
  if (qr <= mid) return query(u << 1, ql, qr, l, mid);
  if (ql > mid) return query(u << 1 | 1, ql, qr, mid + 1, r);
  return merge(query(u << 1, ql, mid, l, mid),
               query(u << 1 | 1, mid + 1, qr, mid + 1, r));
}
int query(int x) {
  int res = f[x];
  if (pt[x]) {
    auto it = query(1, 1, pt[x], 1, n);
    res = std::max(res, f[x] + (rk[x] <= pt[x] && it.first == f[x] ? it.second
                                                                   : it.first));
  }
  if (g[x].size()) res = std::max(res, f[x] + *g[x].rbegin());
  for (int y : L[x]) res = std::max(res, f[x] + f[y] + map[x][y]);
  return res;
}
int main() {
  val = {0, (int)(2e9)};
  read(n), read(s);
  for (int l, r, i = 1; i <= n; i++) {
    read(a[i].l), read(a[i].r), read(a[i].w);
    val.push_back(a[i].l);
    val.push_back(a[i].r);
  }
  std::sort(val.begin(), val.end());
  val.erase(std::unique(val.begin(), val.end()), val.end());
  for (int i = 1; i <= n; i++) {
    ins[std::lower_bound(val.begin(), val.end(), a[i].l) - val.begin()]
        .push_back(i);
    del[std::lower_bound(val.begin(), val.end(), a[i].r) - val.begin()]
        .push_back(i);
  }
  read(m);
  for (int x, i = 1; i <= m; i++) {
    read(x);
    qry.push_back({x, i});
  }
  std::sort(qry.begin(), qry.end());
  for (int i = 1; i <= n; i++) sa[i] = i;
  std::sort(sa + 1, sa + n + 1, [](int i, int j) { return a[i].w < a[j].w; });
  for (int i = 1; i <= n; i++) {
    a[n + 1].w = s - a[i].w;
    rk[sa[i]] = i;
    pt[i] = std::upper_bound(sa + 1, sa + n + 1, n + 1,
                             [](int i, int j) { return a[i].w < a[j].w; }) -
            sa - 1;
  }
  for (int i = 0; i < val.size(); i++) {
    if (i) {
      std::pair<int, int> t;
      if (!set.size()) {
        t = {0, 0};
      } else if (set.size() == 1) {
        if (a[*set.begin()].w > s)
          t = {-1, -1};
        else
          t = {*set.begin(), -1};
      } else if (set.size() == 2) {
        if (a[*set.begin()].w + a[*set.rbegin()].w > s)
          t = {-1, -1};
        else
          t = {*set.begin(), *set.rbegin()};
      } else {
        t = {-1, -1};
      }
      q.push_back({t, val[i] - val[i - 1]});
    }
    for (int x : ins[i]) set.insert(x);
    for (int x : del[i]) set.erase(x);
  }
  for (const auto &it : q)
    if (it.first.first && ~it.first.first && it.first.second &&
        ~it.first.second) {
      edg.push_back(it.first);
    }
  std::sort(edg.begin(), edg.end());
  edg.erase(std::unique(edg.begin(), edg.end()), edg.end());
  for (const auto &it : edg) {
    G[it.first].push_back(it.second);
    G[it.second].push_back(it.first);
  }
  for (const auto &it : edg)
    if (G[it.first].size() > 1 && G[it.second].size() > 1) {
      L[it.first].push_back(it.second);
      L[it.second].push_back(it.first);
    }
  for (int i = 1; i <= n; i++) {
    if (G[i].size() == 1) g[G[i][0]].insert(0);
  }
  int tim = 0, fre = 0, max = 0, k = 0;
  for (const auto &it : q) {
    int u = it.first.first, v = it.first.second, t = it.second;
    if (u == 0 && v == 0) {
      fre += t;
    } else if (u != -1 && v == -1) {
      if (G[u].size() == 1)
        g[G[u][0]].erase(g[G[u][0]].find(f[u] + map[u][G[u][0]]));
      f[u] += t;
      modify(1, rk[u], f[u], 1, n);
      if (G[u].size() == 1) g[G[u][0]].insert(f[u] + map[u][G[u][0]]);
      max = std::max(max, query(u));
      if (G[u].size() == 1) max = std::max(max, query(G[u][0]));
    } else if (u != -1 && v != -1) {
      if (G[u].size() == 1)
        g[G[u][0]].erase(g[G[u][0]].find(f[u] + map[u][G[u][0]]));
      if (G[v].size() == 1)
        g[G[v][0]].erase(g[G[v][0]].find(f[v] + map[v][G[v][0]]));
      map[u][v] += t, map[v][u] += t;
      if (G[u].size() == 1) g[G[u][0]].insert(f[u] + map[u][G[u][0]]);
      if (G[v].size() == 1) g[G[v][0]].insert(f[v] + map[v][G[v][0]]);
      max = std::max(max, std::max(query(u), query(v)));
    }
    tim += t;
    while (k < qry.size() && qry[k].first <= max + fre) {
      ans[qry[k].second] = tim - (max + fre - qry[k].first);
      k++;
    }
  }
  for (int i = 1; i <= m; i++) print(ans[i]), putchar('\n');
}