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;
const int MN = 300010;
struct BIT {
  vector<int> tree;
  void init() { tree = vector<int>(4 * MN, 0); }
  void upd(int idx, int val, int l, int r, int n) {
    if (idx < l || r < idx) return;
    if (l == r) {
      tree[n] = max(tree[n], val);
      return;
    }
    int m = (l + r) >> 1;
    upd(idx, val, l, m, 2 * n);
    upd(idx, val, m + 1, r, 2 * n + 1);
    tree[n] = max(tree[2 * n], tree[2 * n + 1]);
  }
  int quer(int a, int b, int l, int r, int n) {
    if (b < l || r < a) return 0;
    if (a <= l && r <= b) return tree[n];
    int m = (l + r) >> 1;
    int L = quer(a, b, l, m, 2 * n);
    int R = quer(a, b, m + 1, r, 2 * n + 1);
    return max(L, R);
  }
} bit;
struct BIT2 {
  vector<pair<int, int> > tree;
  void init() {
    tree = vector<pair<int, int> >(4 * MN, pair<int, int>(-1, -1));
  }
  void upd(int idx, pair<int, int> val, int l, int r, int n) {
    if (idx < l || r < idx) return;
    if (l == r) {
      tree[n] = max(tree[n], val);
      return;
    }
    int m = (l + r) >> 1;
    upd(idx, val, l, m, 2 * n);
    upd(idx, val, m + 1, r, 2 * n + 1);
    tree[n] = max(tree[2 * n], tree[2 * n + 1]);
  }
  pair<int, int> quer(int a, int b, int l, int r, int n) {
    if (b < l || r < a) return pair<int, int>(-1, -1);
    if (a <= l && r <= b) return tree[n];
    int m = (l + r) >> 1;
    pair<int, int> L = quer(a, b, l, m, 2 * n);
    pair<int, int> R = quer(a, b, m + 1, r, 2 * n + 1);
    return max(L, R);
  }
} sub;
int N, M, C;
struct Info {
  int t, id, s;
  bool operator<(const Info &i) const { return t < i.t; }
};
vector<Info> upd;
vector<pair<int, int> > seg;
vector<pair<int, int> > ord;
vector<int> cost, inv;
vector<int> X;
vector<pair<int, int> > query;
vector<int> ans;
set<int> st;
map<pair<int, int>, int> cross;
vector<int> single;
int sun;
int main() {
  scanf("%d %d", &N, &C);
  cost.resize(N);
  seg.resize(N);
  for (int i = 0; i < N; i++) {
    int l, r, c;
    scanf("%d %d %d", &l, &r, &c);
    seg[i] = pair<int, int>(l, r);
    X.push_back(l);
    X.push_back(r);
    upd.push_back({l, i, 1});
    upd.push_back({r, i, 0});
    cost[i] = c;
    ord.push_back(pair<int, int>(cost[i], i));
  }
  X.push_back(0);
  X.push_back(2e9);
  sort(X.begin(), X.end());
  X.resize(unique(X.begin(), X.end()) - X.begin());
  sort(ord.begin(), ord.end());
  inv.resize(N);
  for (int i = 0; i < N; i++) inv[ord[i].second] = i;
  scanf("%d", &M);
  query.resize(M);
  for (int i = 0; i < M; i++) {
    scanf("%d", &query[i].first);
    query[i].second = i;
  }
  sort(upd.begin(), upd.end());
  sort(query.begin(), query.end());
  int pos1 = 0, pos2 = 0;
  single = vector<int>(N, 0);
  sun = 0;
  bit.init();
  sub.init();
  ans.resize(M);
  for (int i = 1; i < X.size(); i++) {
    while (pos1 < upd.size() && upd[pos1].t <= X[i - 1]) {
      if (upd[pos1].s)
        st.insert(upd[pos1].id);
      else
        st.erase(st.find(upd[pos1].id));
      pos1++;
    }
    int len = X[i] - X[i - 1];
    while (pos2 < M) {
      if (st.size() > 2) break;
      int s = 0, e = len;
      int p = -1;
      while (s <= e) {
        int m = (1LL * s + e) >> 1;
        int mx;
        if (st.size() == 2) {
          set<int>::iterator it = st.begin();
          int a = *it;
          int b = *(++it);
          mx = sun + bit.tree[1];
          if (cost[a] + cost[b] <= C) {
            mx = max(mx, sun + single[a] + single[b] +
                             cross[pair<int, int>(a, b)] + m);
            mx = max(mx, sun + single[a] + single[b] +
                             cross[pair<int, int>(a, b)] + m);
          }
        } else if (st.size() == 1) {
          int a = *st.begin();
          mx = sun + bit.tree[1];
          if (cost[a] <= C) {
            int t = bit.quer(a, a, 0, MN - 1, 1);
            int ts = 0, te = N - 1;
            int tp = -1;
            while (ts <= te) {
              int tm = (ts + te) >> 1;
              if (ord[tm].first <= C - cost[a]) {
                tp = tm;
                ts = tm + 1;
              } else
                te = tm - 1;
            }
            pair<int, int> d = sub.quer(0, min(inv[a] - 1, tp), 0, MN - 1, 1);
            d = max(d, sub.quer(inv[a] + 1, tp, 0, MN - 1, 1));
            int x =
                d == pair<int, int>(-1, -1)
                    ? t + m
                    : max(t + m,
                          m + single[a] + single[d.second] +
                              (cross.find(pair<int, int>(min(a, d.second),
                                                         max(a, d.second))) ==
                                       cross.end()
                                   ? 0
                                   : cross[pair<int, int>(min(a, d.second),
                                                          max(a, d.second))]));
            mx = max(mx, sun + x);
          }
        } else {
          mx = sun + m + bit.tree[1];
        }
        if (mx >= query[pos2].first) {
          p = m;
          e = m - 1;
        } else
          s = m + 1;
      }
      if (p == -1)
        break;
      else {
        ans[query[pos2].second] = X[i - 1] + p;
        pos2++;
      }
    }
    if (st.size() > 2) continue;
    if (st.size() == 2) {
      set<int>::iterator it = st.begin();
      int a = *it;
      int b = *(++it);
      cross[pair<int, int>(a, b)] += len;
      if (cost[a] + cost[b] <= C) {
        bit.upd(a, single[a] + single[b] + cross[pair<int, int>(a, b)], 0,
                MN - 1, 1);
        bit.upd(b, single[a] + single[b] + cross[pair<int, int>(a, b)], 0,
                MN - 1, 1);
      }
    } else if (st.size() == 1) {
      int a = *st.begin();
      single[a] += len;
      sub.upd(inv[a], pair<int, int>(single[a], a), 0, MN - 1, 1);
      if (cost[a] <= C) {
        int t = bit.quer(a, a, 0, MN - 1, 1);
        int s = 0, e = N - 1;
        int p = -1;
        while (s <= e) {
          int m = (s + e) >> 1;
          if (ord[m].first <= C - cost[a]) {
            p = m;
            s = m + 1;
          } else
            e = m - 1;
        }
        pair<int, int> d = sub.quer(0, min(inv[a] - 1, p), 0, MN - 1, 1);
        d = max(d, sub.quer(inv[a] + 1, p, 0, MN - 1, 1));
        int x = d == pair<int, int>(-1, -1)
                    ? t + len
                    : max(t + len,
                          single[a] + single[d.second] +
                              (cross.find(pair<int, int>(min(a, d.second),
                                                         max(a, d.second))) ==
                                       cross.end()
                                   ? 0
                                   : cross[pair<int, int>(min(a, d.second),
                                                          max(a, d.second))]));
        bit.upd(a, x, 0, MN - 1, 1);
      }
    } else {
      sun += len;
    }
  }
  for (int i = 0; i < M; i++) {
    printf("%d\n", ans[i]);
  }
}