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;
struct SegmentTree {
  int sz;
  pair<long long, int> *tree;
  SegmentTree(int pre_sz) {
    sz = 1 << (int)ceil(log2(pre_sz));
    tree = new pair<long long, int>[2 * sz];
    for (int i = 0; i < (sz); i++) {
      tree[sz + i] = make_pair(0, i);
      update(i, 0);
    }
  }
  void update(int idx, long long v) {
    idx += sz;
    tree[idx].first += v;
    for (idx /= 2; idx > 0; idx /= 2) {
      if (tree[idx * 2].first >= tree[idx * 2 + 1].first)
        tree[idx] = tree[idx * 2];
      else
        tree[idx] = tree[idx * 2 + 1];
    }
  }
  int query(int lo, int hi) {
    lo += sz;
    hi += sz;
    int bestI = -1;
    while (lo <= hi) {
      if (lo % 2 == 1) {
        if (bestI == -1 || tree[lo].first > tree[sz + bestI].first)
          bestI = tree[lo].second;
        lo++;
      }
      if (hi % 2 == 0) {
        if (bestI == -1 || tree[hi].first > tree[sz + bestI].first)
          bestI = tree[hi].second;
        hi--;
      }
      lo /= 2;
      hi /= 2;
    }
    return bestI;
  }
};
int n, m;
long long C, single[300000], opt[300000];
vector<tuple<long long, long long, long long>> clouds;
vector<pair<long long, int>> queries;
long long answerToQuery[300000];
unordered_map<long long, long long> cross;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> C;
  vector<pair<long long, int>> toProcess;
  for (int i = 0; i < (n); i++) {
    long long l, r, c;
    cin >> l >> r >> c;
    clouds.push_back(make_tuple(c, l, r));
  }
  sort(clouds.begin(), clouds.end());
  for (int i = 0; i < (n); i++) {
    long long l = get<1>(clouds[i]);
    long long r = get<2>(clouds[i]);
    toProcess.push_back(make_pair(l, i));
    toProcess.push_back(make_pair(r, i));
  }
  sort(toProcess.begin(), toProcess.end());
  cin >> m;
  for (int i = 0; i < (m); i++) {
    long long k;
    cin >> k;
    queries.push_back(make_pair(k, i));
  }
  sort(queries.begin(), queries.end());
  int atQuery = 0;
  unordered_set<int> open;
  long long free = 0;
  long long top = 0;
  long long lastSpot = 0;
  SegmentTree st(n);
  for (const pair<long long, long long> p : toProcess) {
    long long len = p.first - lastSpot;
    if (open.empty())
      free += len;
    else if (open.size() == 1) {
      int a = *(open.begin());
      if (get<0>(clouds[a]) <= C) {
        st.update(a, -single[a] - 1);
        single[a] += len;
        opt[a] += len;
        int searchEnd = upper_bound(clouds.begin(), clouds.end(),
                                    make_tuple(C - get<0>(clouds[a]),
                                               10000000000, 10000000000)) -
                        clouds.begin() - 1;
        if (searchEnd >= 0) {
          int other = st.query(0, searchEnd);
          if (other != a) {
            long long total =
                single[a] + single[other] +
                cross[(long long)min(a, other) * (n + 1) + max(a, other)];
            opt[a] = max(opt[a], total);
            opt[other] = max(opt[other], total);
            top = max(top, max(opt[a], opt[other]));
          }
        }
        top = max(top, opt[a]);
        st.update(a, single[a] + 1);
      }
    } else if (open.size() == 2) {
      int a = min(*(open.begin()), *(++open.begin()));
      int b = max(*(open.begin()), *(++open.begin()));
      cross[(long long)a * (n + 1) + b] += len;
      if (get<0>(clouds[a]) + get<0>(clouds[b]) <= C) {
        opt[a] = max(opt[a],
                     cross[(long long)a * (n + 1) + b] + single[a] + single[b]);
        opt[b] = max(opt[b],
                     cross[(long long)a * (n + 1) + b] + single[a] + single[b]);
      }
      top = max(top, max(opt[a], opt[b]));
    }
    if (open.count(p.second))
      open.erase(p.second);
    else
      open.insert(p.second);
    lastSpot = p.first;
    while (atQuery < m && queries[atQuery].first <= free + top) {
      answerToQuery[queries[atQuery].second] =
          lastSpot - free - top + queries[atQuery].first;
      atQuery++;
    }
    if (atQuery == m) break;
  }
  while (atQuery < m) {
    answerToQuery[queries[atQuery].second] =
        lastSpot - free - top + queries[atQuery].first;
    atQuery++;
  }
  for (int i = 0; i < (m); i++) {
    cout << answerToQuery[i] << "\n";
  }
  return 0;
}