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;
int l[300005], r[300005], c[300005];
int m;
int k[300005];
vector<int> it;
int T;
int il[300005], ir[300005];
vector<int> is[600005], er[600005];
vector<int> w[600005];
bool gd[600005];
int ei0[600005], ei1[600005];
vector<pair<int, int> > el;
int ev[600005];
int es[300005], ee[300005];
int bst[600005];
int tvs[300005];
pair<int, int> sci[300005];
int mxu[300005];
int scl[300005];
int rt[600005];
int qmx(int l, int r) {
  int ans = -1;
  for (l += n, r += n; l < r; l /= 2, r /= 2) {
    if (l & 1) ans = max(ans, rt[l++]);
    if (r & 1) ans = max(ans, rt[--r]);
  }
  return ans;
}
void adv(int i, int x) {
  rt[i += n] += x;
  for (i /= 2; i > 0; i /= 2) {
    rt[i] = max(rt[2 * i], rt[2 * i + 1]);
  }
}
void addtvs(int i, int v) {
  tvs[i] += v;
  adv(scl[i], v);
}
int clcv(int i) {
  if (ee[i] - es[i] > 500 || c[i] > C) return 0;
  int res = tvs[i];
  for (int j = (es[i]); j < (ee[i]); j++) {
    if (c[el[j].first] + c[el[j].second] <= C) {
      assert(el[j].first == i);
      res = max(res, ev[j] + tvs[el[j].first] + tvs[el[j].second]);
    }
  }
  int mx = -1;
  if (scl[i] < mxu[i]) {
    mx = max(qmx(0, scl[i]), qmx(scl[i] + 1, mxu[i]));
  } else {
    mx = qmx(0, mxu[i]);
  }
  if (mx != -1) res = max(res, mx + tvs[i]);
  return res;
}
int main() {
  scanf("%d %d", &n, &C);
  for (int i = (0); i < (n); i++) scanf("%d %d %d", l + i, r + i, c + i);
  scanf("%d", &m);
  for (int i = (0); i < (m); i++) scanf("%d", k + i);
  for (int i = (0); i < (n); i++) sci[i] = make_pair(c[i], i);
  sort(sci, sci + n);
  for (int i = (0); i < (n); i++) {
    scl[sci[i].second] = i;
    mxu[i] = lower_bound(sci, sci + n, make_pair(C - c[i] + 1, -1)) - sci;
  }
  for (int i = (0); i < (n); i++) it.push_back(l[i]);
  for (int i = (0); i < (n); i++) it.push_back(r[i]);
  it.push_back(2e9 + 5);
  it.push_back(0);
  sort(it.begin(), it.end());
  it.resize(unique(it.begin(), it.end()) - it.begin());
  T = int(it.size());
  for (int i = (0); i < (n); i++) {
    il[i] = lower_bound(it.begin(), it.end(), l[i]) - it.begin();
    ir[i] = lower_bound(it.begin(), it.end(), r[i]) - it.begin();
    is[il[i]].push_back(i);
    er[ir[i]].push_back(i);
  }
  set<int> wh;
  for (int i = (0); i < (T - 1); i++) {
    for (int x : is[i]) wh.insert(x);
    for (int x : er[i]) wh.erase(x);
    if (int(wh.size()) <= 2) {
      for (int x : wh) w[i].push_back(x);
      gd[i] = true;
      if (int(w[i].size()) == 2) {
        el.emplace_back(w[i][0], w[i][1]);
        el.emplace_back(w[i][1], w[i][0]);
      }
    }
  }
  sort(el.begin(), el.end());
  el.resize(unique(el.begin(), el.end()) - el.begin());
  memset(es, -1, sizeof es);
  memset(ee, -1, sizeof ee);
  for (int i = (0); i < (int(el.size())); i++) {
    if (es[el[i].first] == -1) es[el[i].first] = i;
    ee[el[i].first] = i + 1;
  }
  for (int i = (0); i < (T); i++)
    if (int(w[i].size()) == 2) {
      ei0[i] = lower_bound(el.begin(), el.end(), make_pair(w[i][0], w[i][1])) -
               el.begin();
      ei1[i] = lower_bound(el.begin(), el.end(), make_pair(w[i][1], w[i][0])) -
               el.begin();
    }
  for (int i = (0); i < (n); i++)
    if (ee[i] - es[i] > 500 && c[i] <= C) {
      memset(tvs, 0, sizeof tvs);
      for (int j = (0); j < (n); j++)
        if (c[i] + c[j] > C) tvs[j] = -2e9 - 10;
      int oh = 0;
      int cbst = 0;
      for (int j = (0); j < (T - 1); j++) {
        if (gd[j]) {
          int ln = it[j + 1] - it[j];
          if (int(w[j].size()) == 0 ||
              (int(w[j].size()) == 1 && w[j][0] == i)) {
            oh += ln;
          } else if (int(w[j].size()) == 1) {
            cbst = max(cbst, tvs[w[j][0]] += ln);
          } else if (int(w[j].size()) == 2 && (w[j][0] == i || w[j][1] == i)) {
            cbst = max(cbst, tvs[w[j][0] ^ w[j][1] ^ i] += ln);
          }
        }
        bst[j + 1] = max(bst[j + 1], cbst + oh);
      }
    }
  memset(tvs, 0, sizeof tvs);
  int oh = 0;
  int cbst = 0;
  for (int j = (0); j < (T - 1); j++) {
    if (gd[j]) {
      int ln = it[j + 1] - it[j];
      if (int(w[j].size()) == 0) {
        oh += ln;
      } else if (int(w[j].size()) == 1) {
        addtvs(w[j][0], ln);
      } else {
        ev[ei0[j]] += ln;
        ev[ei1[j]] += ln;
      }
      for (int x : w[j]) cbst = max(cbst, clcv(x));
    }
    bst[j + 1] = max(bst[j + 1], cbst + oh);
  }
  for (int i = (0); i < (m); i++) {
    int j = lower_bound(bst, bst + T, k[i]) - bst;
    int ex = bst[j] - k[i];
    int ep = it[j];
    printf("%d\n", ep - ex);
  }
}