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>
int n, C, orig[600010], top, stk[300010], all, Add[300010], One[300010],
    cost[600010], ctop;
struct info {
  int mx, ord, skdmx;
} c[3000010];
info merge(info a, info b) {
  info c;
  if (a.mx > b.mx)
    c = a, c.skdmx = std::max(c.skdmx, b.mx);
  else
    c = b, c.skdmx = std::max(c.skdmx, a.mx);
  return c;
}
void build(int root, int l, int r) {
  c[root] = (info){-0x7f7f7f7f, 0, -0x7f7f7f7f};
  if (l == r) return;
  build(root << 1, l, (l + r) >> 1);
  build(root << 1 | 1, ((l + r) >> 1) + 1, r);
}
void update(int root, int l, int r, int e, info x) {
  if (l == r) {
    c[root] = x;
    return;
  }
  if ((l + r) >> 1 >= e)
    update(root << 1, l, (l + r) >> 1, e, x);
  else
    update(root << 1 | 1, ((l + r) >> 1) + 1, r, e, x);
  c[root] = merge(c[root << 1], c[root << 1 | 1]);
}
info query(int root, int l, int r, int el, int er) {
  if (el > r || er < l) return (info){-0x7f7f7f7f, 0, -0x7f7f7f7f};
  if (el <= l && er >= r) return c[root];
  return merge(query(root << 1, l, (l + r) >> 1, el, er),
               query(root << 1 | 1, ((l + r) >> 1) + 1, r, el, er));
}
bool Del[300010];
long long f[600010], g[600010];
struct line {
  int l, r, c;
} num[300001];
std::vector<int> add[600010], del[600010];
bool cmp(line a, line b) { return (a.r < b.r) || (a.r == b.r && a.l < b.l); }
int main() {
  scanf("%d%d", &n, &C);
  for (int i = 1; i <= n; i++)
    scanf("%d%d%d", &num[i].l, &num[i].r, &num[i].c),
        orig[++top] = num[i].l, orig[++top] = num[i].r, cost[++ctop] = num[i].c;
  cost[++ctop] = 0;
  std::sort(cost + 1, cost + ctop + 1);
  ctop = std::unique(cost + 1, cost + ctop + 1) - cost - 1;
  build(1, 1, ctop);
  orig[++top] = 0;
  orig[++top] = 0x7f7f7f7f;
  std::sort(orig + 1, orig + top + 1);
  top = std::unique(orig + 1, orig + top + 1) - orig - 1;
  for (int i = 1; i <= n; i++)
    num[i].l = std::lower_bound(orig + 1, orig + top + 1, num[i].l) - orig,
    num[i].r = std::lower_bound(orig + 1, orig + top + 1, num[i].r) - orig - 1;
  for (int i = 1; i <= n; i++)
    add[num[i].l].push_back(i), del[num[i].r].push_back(i);
  g[0] = -1e18;
  for (int i = 1, cnt = 0, last1 = -1, last2 = -1, Sum = 0, empty = 0; i <= top;
       i++) {
    f[i] = std::max(f[i - 1], g[i - 1] + orig[i] - 1);
    g[i] = -1e18;
    for (int j = 0; j < add[i].size(); j++) stk[++all] = add[i][j], ++cnt;
    if (!cnt)
      g[i] = std::max(g[i], f[i] - orig[i] + 1), empty += orig[i + 1] - orig[i];
    else if (cnt == 1) {
      while (Del[stk[all]]) --all;
      if (num[stk[all]].c <= C) {
        Add[stk[all]] += orig[i + 1] - orig[i];
        g[i] = std::max(g[i], 1ll * empty + 1ll * Add[stk[all]] +
                                  1ll * One[stk[all]] - 1ll * orig[i + 1] + 1);
        auto now = query(
            1, 1, ctop, 1,
            std::upper_bound(cost + 1, cost + ctop + 1, C - num[stk[all]].c) -
                cost - 1);
        g[i] = std::max(g[i],
                        1ll * empty + 1ll * Add[stk[all]] +
                            1ll * (now.ord == stk[all] ? now.skdmx : now.mx) -
                            1ll * orig[i + 1] + 1);
        update(
            1, 1, ctop,
            std::lower_bound(cost + 1, cost + ctop + 1, num[stk[all]].c) - cost,
            (info){Add[stk[all]], stk[all], -0x7f7f7f7f});
      }
    } else if (cnt == 2) {
      while (Del[stk[all]]) --all;
      int p1 = stk[all];
      --all;
      while (Del[stk[all]]) --all;
      int p2 = stk[all];
      stk[++all] = p1;
      if (num[p1].c + num[p2].c <= C) {
        if (last1 != p1 || last2 != p2) Sum = 0, last1 = p1, last2 = p2;
        Sum += orig[i + 1] - orig[i];
        g[i] = std::max(
            g[i], 1ll * empty + Sum + Add[p1] + Add[p2] - orig[i + 1] + 1);
        One[p2] = std::max(One[p2], Sum + Add[p1]);
        One[p1] = std::max(One[p1], Sum + Add[p2]);
      }
    }
    for (int j = 0; j < del[i].size(); j++) Del[del[i][j]] = 1, --cnt;
  }
  int m;
  scanf("%d", &m);
  for (int i = 1, k; i <= m; i++) {
    scanf("%d", &k);
    int l = 1, r = top - 1, mid, ans = -1;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (std::max(f[mid], g[mid] + 1ll * orig[mid + 1] - 1) >= 1ll * k)
        ans = mid, r = mid - 1;
      else
        l = mid + 1;
    }
    printf("%lld\n", std::max(1ll * orig[ans], 1ll * k - 1ll * g[ans]) + 1ll);
  }
}