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;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool smin(T &a, const T &b) {
  return a > b ? a = b : a;
}
template <typename T>
inline bool smax(T &a, const T &b) {
  return a < b ? a = b : a;
}
const int N = (int)3e5 + 5, mod = (int)0;
int ok[N], req[N], bl[N], br[N], bm[N], xcs[N], o[N], rev[N], xl[N], xr[N],
    xc[N], seg[N << 2], alone[N], val[N], ans[N], eo[N];
pair<int, int> event[N * 4];
bool by_req(int a, int b) { return req[a] < req[b]; }
bool by_xc(int a, int b) { return xc[a] < xc[b]; }
void update(int pos, int first, int v = 1, int b = 0, int e = N) {
  if (b + 1 == e) {
    seg[v] = max(seg[v], first);
    return;
  }
  int m = b + e >> 1, l = v << 1, r = l | 1;
  if (pos < m) {
    update(pos, first, l, b, m);
  } else {
    update(pos, first, r, m, e);
  }
  seg[v] = max(seg[l], seg[r]);
}
int query(int i, int j, int v = 1, int b = 0, int e = N) {
  if (i >= e || b >= j) return 0;
  if (i <= b && e <= j) return seg[v];
  int m = b + e >> 1, l = v << 1, r = l | 1;
  return max(query(i, j, l, b, m), query(i, j, r, m, e));
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, bud;
  cin >> n >> bud;
  for (int j = 0; j < n; ++j) {
    cin >> xl[j] >> xr[j] >> xc[j];
    o[j] = j;
    xcs[j] = xc[j];
  }
  int q;
  cin >> q;
  for (int j = 0; j < q; ++j)
    cin >> req[j], bl[j] = 0, br[j] = 2e9 + 1, eo[j] = j;
  sort(xcs, xcs + n);
  sort(o, o + n, by_xc);
  sort(eo, eo + q, by_req);
  int pt = 0;
  for (int j = 0; j < n; ++j) rev[o[j]] = j;
  memset(ok, 0, sizeof ok);
  memset(seg, 0, sizeof seg);
  memset(alone, 0, sizeof alone);
  memset(val, 0, sizeof val);
  int sz = 0, c = 0;
  for (int j = 0; j < n; ++j) {
    event[sz++] = make_pair(xl[j], j << 2 | 0);
    event[sz++] = make_pair(xr[j], j << 2 | 1);
  }
  event[sz++] = make_pair((int)2e9 + 1, 2);
  set<int> op;
  map<pair<int, int>, int> share;
  sort(event, event + sz);
  int last = 0;
  int res = 0, add = 0;
  for (int j = 0; j < sz; ++j) {
    int pos = event[j].first, t = event[j].second;
    if ((int)op.size() == 1) {
      int o = *(op.begin());
      if (xc[o] <= bud) {
        val[o] += pos - last;
        alone[o] += pos - last;
        res = max(res, add + val[o]);
        res = max(res, alone[o] + add);
        int p = rev[o];
        update(p, alone[o]);
        int allow_r = upper_bound(xcs, xcs + n, bud - xc[o]) - xcs;
        if (p < allow_r) {
          res = max(res,
                    alone[o] + max(query(0, p), query(p + 1, allow_r)) + add);
        } else {
          res = max(res, alone[o] + query(0, allow_r) + add);
        }
      }
    } else if ((int)op.size() == 2) {
      auto it = op.begin();
      int first = *it, second = *(++it);
      if (xc[first] + xc[second] <= bud) {
        share[make_pair(first, second)] += pos - last;
        int g = share[make_pair(first, second)] + alone[first] + alone[second];
        res = max(res, add + g);
        val[first] = max(val[first], g);
        val[second] = max(val[second], g);
      }
    } else if ((int)op.size() == 0) {
      add += pos - last;
      res += pos - last;
    }
    while (pt < q && res >= req[eo[pt]]) {
      ans[eo[pt]] = pos - (res - req[eo[pt]]);
      ++pt;
    }
    if ((t & 3) == 0) {
      op.insert(t >> 2);
    } else if ((t & 3) == 1) {
      op.erase(t >> 2);
    } else if ((t & 3) == 2) {
      int id = t >> 2;
      if (req[id] <= res) {
        ok[id] = 1;
      } else {
        ok[id] = 0;
      }
      --c;
      if (!c) break;
    } else {
      assert(0);
    }
    last = pos;
  }
  for (int j = 0; j < q; ++j) cout << ans[j] << '\n';
}