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, q, C, ans, base_ans, res[((int)601 * 1000)];
int _l[((int)601 * 1000)], _r[((int)601 * 1000)], _c[((int)601 * 1000)];
set<int> _add[2 * ((int)601 * 1000)], _rem[2 * ((int)601 * 1000)], _now;
int sz = 1, cnt[((int)601 * 1000)], cnt_e[2 * ((int)601 * 1000)],
    best[((int)601 * 1000)];
map<pair<int, int>, int> mp;
vector<pair<int, int> > e[((int)601 * 1000)], big_e[((int)601 * 1000)], qu;
vector<int> vec, v_c;
pair<int, int> fen[((int)601 * 1000)];
void change(pair<int, int> &x, int y) {
  if (cnt[x.first] < cnt[y])
    x.second = x.first, x.first = y;
  else if (cnt[x.second] < cnt[y] && y != x.first)
    x.second = y;
}
void update(int x, int v) {
  for (; x < ((int)601 * 1000); x += x & -x) change(fen[x], v);
}
pair<int, int> query(int x) {
  pair<int, int> res = {0, 0};
  for (; x > 0; x -= x & -x)
    change(res, fen[x].first), change(res, fen[x].second);
  return res;
}
int main() {
  scanf("%d%d", &n, &C);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &_l[i], &_r[i], &_c[i]);
    vec.push_back(_l[i]);
    vec.push_back(_r[i]);
    v_c.push_back(_c[i]);
  }
  v_c.push_back(-1);
  sort(v_c.begin(), v_c.end());
  v_c.resize(unique(v_c.begin(), v_c.end()) - v_c.begin());
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
  for (int i = 1; i <= n; i++) {
    _add[lower_bound(vec.begin(), vec.end(), _l[i]) - vec.begin()].insert(i);
    _rem[lower_bound(vec.begin(), vec.end(), _r[i]) - vec.begin()].insert(i);
  }
  for (int i = 0; i < vec.size(); i++) {
    for (auto u : _add[i]) _now.insert(u);
    for (auto u : _rem[i]) _now.erase(u);
    if (_now.size() == 2) {
      int v = *_now.begin(), u = *_now.rbegin();
      if (v > u) swap(v, u);
      if (!mp[{v, u}]) {
        mp[{v, u}] = sz;
        e[v].push_back({u, sz});
        e[u].push_back({v, sz});
        sz++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (e[i].size() < ((int)500)) continue;
    for (auto u : e[i]) big_e[u.first].push_back({i, u.second});
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int x;
    scanf("%d", &x);
    if (!vec.size()) printf("%d\n", x);
    qu.push_back({x, i});
  }
  if (!vec.size()) return 0;
  sort(qu.begin(), qu.end());
  reverse(qu.begin(), qu.end());
  base_ans = vec[0];
  while (qu.size() && qu.back().first <= ans + base_ans)
    res[qu.back().second] = qu.back().first, qu.pop_back();
  for (int i = 0; i < (int)vec.size() - 1; i++) {
    for (auto u : _add[i]) _now.insert(u);
    for (auto u : _rem[i]) _now.erase(u);
    int len = vec[i + 1] - vec[i];
    if (_now.size() == 2) {
      int v = *_now.begin(), u = *_now.rbegin();
      if (_c[v] + _c[u] > C) continue;
      if (v > u) swap(v, u);
      int id = mp[{v, u}];
      cnt_e[id] += len;
      ans = max(ans, cnt[v] + cnt[u] + cnt_e[id]);
      if (e[v].size() >= ((int)500)) best[v] = max(best[v], cnt[u] + cnt_e[id]);
      if (e[u].size() >= ((int)500)) best[u] = max(best[u], cnt[v] + cnt_e[id]);
    }
    if (_now.size() == 1) {
      int v = *_now.begin();
      if (_c[v] > C) continue;
      cnt[v] += len;
      ans = max(ans, cnt[v]);
      update(lower_bound(v_c.begin(), v_c.end(), _c[v]) - v_c.begin(), v);
      int id = upper_bound(v_c.begin(), v_c.end(), C - _c[v]) - v_c.begin() - 1;
      if (id != 0) {
        pair<int, int> p = query(id);
        if (p.first != v)
          ans = max(ans, cnt[v] + cnt[p.first]);
        else
          ans = max(ans, cnt[v] + cnt[p.second]);
      }
      int now = 0;
      if (e[v].size() >= ((int)500))
        now = best[v];
      else
        for (auto u : e[v])
          if (_c[v] + _c[u.first] <= C)
            now = max(now, cnt_e[u.second] + cnt[u.first]);
      now += cnt[v];
      ans = max(ans, now);
      for (auto u : big_e[v])
        if (_c[v] + _c[u.first] <= C)
          best[u.first] = max(best[u.first], cnt[v] + cnt_e[u.second]);
    }
    if (_now.size() == 0) base_ans += len;
    while (qu.size() && qu.back().first <= ans + base_ans)
      res[qu.back().second] = vec[i + 1] - (ans + base_ans - qu.back().first),
      qu.pop_back();
  }
  while (qu.size())
    res[qu.back().second] = vec.back() + qu.back().first - (ans + base_ans),
    qu.pop_back();
  for (int i = 0; i < q; i++) printf("%d\n", res[i]);
  return 0;
}