#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;
}
