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;
int n, C, nn, m, single[300010], opt[300010], tmp[300010];
struct clouds {
  int l, r, c;
} cl[300010];
struct th {
  int pos, type, id;
} a[600010];
struct query {
  int x, id, ans;
} q[300010];
struct tree {
  int l, r;
  pair<int, int> c;
  tree *lc, *rc;
  tree(int l, int r) : l(l), r(r), c(0, l), lc(NULL), rc(NULL) {}
} * root;
map<int, int> cross[300010];
int cmp(th x, th y) { return x.pos == y.pos ? x.type < y.type : x.pos < y.pos; }
int cmp1(query x, query y) { return x.x < y.x; }
int cmp2(query x, query y) { return x.id < y.id; }
int cmp3(clouds x, clouds y) { return x.c < y.c; }
tree *bt(int l, int r) {
  tree *i = new tree(l, r);
  if (l < r) {
    int md = l + r >> 1;
    i->lc = bt(l, md);
    i->rc = bt(md + 1, r);
  }
  return i;
}
void chg(tree *i, int p, int x) {
  if (i->l == i->r) {
    i->c.first = x;
    return;
  }
  int md = i->l + i->r >> 1;
  if (p <= md)
    chg(i->lc, p, x);
  else
    chg(i->rc, p, x);
  i->c = max(i->lc->c, i->rc->c);
}
pair<int, int> get(tree *i, int l, int r) {
  if (l > r) return make_pair(-1, -1);
  if (i->l == l && i->r == r) {
    return i->c;
  }
  int md = i->l + i->r >> 1;
  if (r <= md)
    return get(i->lc, l, r);
  else if (l > md)
    return get(i->rc, l, r);
  else
    return max(get(i->lc, l, md), get(i->rc, md + 1, r));
}
int main() {
  scanf("%d%d", &n, &C);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &cl[i].l, &cl[i].r, &cl[i].c);
  }
  sort(cl, cl + n, cmp3);
  for (int i = 0; i < n; i++) tmp[i] = cl[i].c;
  root = bt(0, n - 1);
  for (int i = 0; i < n; i++) {
    a[i << 1] = {cl[i].l, 1, i};
    a[i << 1 | 1] = {cl[i].r, 0, i};
  }
  nn = n << 1;
  sort(a, a + nn, cmp);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &q[i].x);
    q[i].id = i;
  }
  sort(q, q + m, cmp1);
  set<int> s;
  int fre = 0, ans = 0, now = 0, j = 0;
  for (int i = 0; i < nn; i++) {
    int delta = a[i].pos - now;
    now = a[i].pos;
    if (s.empty())
      fre += delta;
    else if (s.size() == 1) {
      int x = *s.begin();
      single[x] += delta;
      chg(root, x, single[x]);
      opt[x] += delta;
      int rest = C - cl[x].c;
      if (rest >= 0) {
        int hh = upper_bound(tmp, tmp + n, rest) - tmp - 1;
        if (x <= hh) {
          auto hh1 = get(root, 0, x - 1), hh2 = get(root, x + 1, hh);
          if (hh1.second != -1)
            opt[x] = max(
                opt[x],
                single[x] + hh1.first +
                    (cross[x].count(hh1.second) ? cross[x][hh1.second] : 0));
          if (hh2.second != -1)
            opt[x] = max(
                opt[x],
                single[x] + hh2.first +
                    (cross[x].count(hh2.second) ? cross[x][hh2.second] : 0));
        } else {
          auto oo = get(root, 0, hh);
          if (oo.second != -1)
            opt[x] =
                max(opt[x],
                    single[x] + oo.first +
                        (cross[x].count(oo.second) ? cross[x][oo.second] : 0));
        }
        ans = max(ans, opt[x]);
      }
    } else if (s.size() == 2) {
      int x = *s.begin(), y = *s.rbegin();
      cross[x][y] += delta;
      cross[y][x] += delta;
      if (cl[x].c + cl[y].c <= C) {
        opt[x] = max(opt[x], single[x] + single[y] + cross[x][y]);
        opt[y] = max(opt[y], single[x] + single[y] + cross[x][y]);
        ans = max({ans, opt[x], opt[y]});
      }
    }
    while (j < m && q[j].x <= ans + fre)
      q[j].ans = now - (ans + fre - q[j].x), j++;
    if (a[i].type == 1)
      s.insert(a[i].id);
    else
      s.erase(a[i].id);
  }
  while (j < m) q[j].ans = q[j].x - ans - fre + now, j++;
  sort(q, q + m, cmp2);
  for (int i = 0; i < m; i++) printf("%d\n", q[i].ans);
}