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;
mt19937 rnd(time(NULL));
const int NMAX = 300000;
int single[NMAX];
map<int, int> cross[NMAX];
int opt[NMAX];
struct Cloud {
  int l, r, c;
};
struct Treap {
  struct Node {
    Node *l, *r;
    int priority;
    int dp;
    pair<int, int> key;
    Node() : l(nullptr), r(nullptr), priority(rnd()), dp(-1), key(-1, -1) {}
    Node(pair<int, int> p)
        : l(nullptr), r(nullptr), priority(rnd()), dp(p.second), key(p) {}
  };
  Node* root;
  Node* fix(Node* t) {
    if (!t) return t;
    t->dp = t->key.second;
    if (t->l)
      if (single[t->dp] < single[t->l->dp]) t->dp = t->l->dp;
    if (t->r)
      if (single[t->dp] < single[t->r->dp]) t->dp = t->r->dp;
    return t;
  }
  pair<Node*, Node*> split(Node* t, pair<int, int> key) {
    if (!t) return {t, t};
    if (t->key < key) {
      auto p = split(t->r, key);
      t->r = p.first;
      return {fix(t), p.second};
    } else {
      auto p = split(t->l, key);
      t->l = p.second;
      return {p.first, fix(t)};
    }
  }
  Node* merge(Node* l, Node* r) {
    if (!l) return r;
    if (!r) return l;
    if (l->priority > r->priority) {
      l->r = merge(l->r, r);
      return fix(l);
    } else {
      r->l = merge(l, r->l);
      return fix(r);
    }
  }
  Treap() : root(nullptr) {}
  void push(pair<int, int> key) {
    auto p = split(root, key);
    Node* node = new Node(key);
    root = merge(merge(p.first, node), p.second);
  }
  void pop(pair<int, int> key) {
    auto p = split(root, key);
    auto q = split(p.second, pair<int, int>(key.first, key.second + 1));
    root = merge(p.first, q.second);
  }
  int query(int c) {
    auto p = split(root, pair<int, int>(c + 1, -1));
    int ret = p.first ? p.first->dp : -1;
    root = merge(p.first, p.second);
    return ret;
  }
};
pair<int, int> queries[NMAX];
int ans[NMAX];
int N, C, M;
struct Event {
  int x, tp, id;
  bool operator<(const Event& rhs) const {
    if (x != rhs.x) return x < rhs.x;
    if (tp != rhs.tp) return tp < rhs.tp;
    return id < rhs.id;
  }
};
void process(const vector<Cloud>& clouds) {
  if (clouds.empty()) {
    for (int i = 0; i < M; i++) ans[queries[i].second] = queries[i].first;
    return;
  }
  vector<Event> events;
  for (int i = 0; i < N; i++) {
    const auto& cl = clouds[i];
    events.push_back({cl.l, 1, i});
    events.push_back({cl.r, 0, i});
  }
  sort(events.begin(), events.end());
  int zero = 0, last = 0, best = 0, q = 0;
  set<int> cover;
  Treap treap;
  for (const auto& ev : events) {
    if (cover.size() == 0) {
      zero += ev.x - last;
    } else if (cover.size() == 1) {
      int a = *cover.begin();
      if (clouds[a].c <= C) {
        treap.pop({clouds[a].c, a});
        opt[a] += ev.x - last;
        single[a] += ev.x - last;
        best = max(best, opt[a]);
        int b = treap.query(C - clouds[a].c);
        if (b >= 0) {
          opt[a] = max(opt[a], single[a] + single[b] +
                                   (cross[a].count(b) ? cross[a][b] : 0));
          best = max(best, opt[a]);
        }
        treap.push({clouds[a].c, a});
      }
    } else if (cover.size() == 2) {
      auto it = cover.begin();
      int a = *it, b = *next(it);
      if (clouds[a].c + clouds[b].c <= C) {
        cross[a][b] += ev.x - last;
        cross[b][a] += ev.x - last;
        opt[a] = max(opt[a], single[a] + single[b] + cross[a][b]);
        opt[b] = max(opt[b], single[a] + single[b] + cross[b][a]);
        best = max({best, opt[a], opt[b]});
      }
    }
    while (q < M && queries[q].first <= best + zero) {
      ans[queries[q].second] = ev.x - (best + zero - queries[q].first);
      q++;
    }
    last = ev.x;
    if (ev.tp)
      cover.insert(ev.id);
    else
      cover.erase(ev.id);
  }
  while (q < M) {
    ans[queries[q].second] = events.back().x - (best + zero - queries[q].first);
    q++;
  }
}
int main() {
  scanf("%d%d", &N, &C);
  vector<Cloud> clouds;
  for (int i = 0; i < N; i++) {
    int l, r, c;
    scanf("%d%d%d", &l, &r, &c);
    clouds.push_back({l, r, c});
  }
  scanf("%d", &M);
  for (int i = 0; i < M; i++) {
    int q;
    scanf("%d", &q);
    queries[i] = {q, i};
  }
  sort(queries, queries + M);
  process(clouds);
  for (int i = 0; i < M; i++) printf("%d\n", ans[i]);
}