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 N = 3e5 + 5;
const int inf = (signed)(~0u >> 1);
typedef class Event {
 public:
  int p, op, id;
  Event(int p, int op, int id) : p(p), op(op), id(id) {}
  bool operator<(Event b) const { return p < b.p; }
} Event;
typedef class pii {
 public:
  int x, y;
  pii(int x, int y) : x(x), y(y) { (x > y) && (x = y); }
  bool operator<(pii b) const { return (x ^ b.x) ? (x < b.x) : (y < b.y); }
} pii;
typedef class SegTreeNode {
 public:
  int v;
  SegTreeNode *l, *r;
  SegTreeNode() {}
  void push_up() { v = max(l->v, r->v); }
} SegTreeNode;
SegTreeNode pool[N << 1];
SegTreeNode *_top = pool;
typedef class SegmentTree {
 public:
  int n;
  SegTreeNode *rt;
  SegmentTree() {}
  SegmentTree(int n) : n(n) { build(rt, 1, n); }
  void build(SegTreeNode *&p, int l, int r) {
    p = _top++;
    if (l == r) {
      return;
    }
    int mid = (l + r) >> 1;
    build(p->l, l, mid);
    build(p->r, mid + 1, r);
  }
  void modify(SegTreeNode *p, int l, int r, int idx, int v) {
    if (l == r) {
      p->v += v;
      return;
    }
    int mid = (l + r) >> 1;
    if (idx <= mid) {
      modify(p->l, l, mid, idx, v);
    } else {
      modify(p->r, mid + 1, r, idx, v);
    }
    p->push_up();
  }
  int query(SegTreeNode *p, int l, int r, int ql, int qr) {
    if (l == ql && r == qr) {
      return p->v;
    }
    int mid = (l + r) >> 1;
    if (qr <= mid) {
      return query(p->l, l, mid, ql, qr);
    } else if (ql > mid) {
      return query(p->r, mid + 1, r, mid + 1, qr);
    }
    int a = query(p->l, l, mid, ql, mid);
    int b = query(p->r, mid + 1, r, mid + 1, qr);
    return max(a, b);
  }
  void modify(int idx, int v) { modify(rt, 1, n, idx, v); }
  int query(int l, int r) {
    if (l > r) {
      return 0;
    }
    return query(rt, 1, n, l, r);
  }
} SegmentTree;
int n, C, m;
set<int> cur;
int f[N], g[N];
map<pii, int> G;
vector<Event> E;
vector<int> st, fr;
int L[N], R[N], c[N];
pair<int, int> ps[N];
int id[N];
SegmentTree seg;
int get_position(int cost) {
  int l = 1, r = n, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (ps[mid].first <= cost) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return l - 1;
}
int main() {
  scanf("%d%d", &n, &C);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", L + i, R + i, c + i);
    E.emplace_back(L[i], 1, i);
    E.emplace_back(R[i], -1, i);
    ps[i] = pair<int, int>(c[i], i);
  }
  E.emplace_back(0, 0, 0);
  sort(E.begin(), E.end());
  sort(ps + 1, ps + n + 1);
  for (int i = 1; i <= n; i++) {
    id[ps[i].second] = i;
  }
  if (n) {
    seg = SegmentTree(n);
  }
  int freelen = 0, blank = 0;
  for (int i = 0, j = 0; i < (signed)E.size(); i = j) {
    for (; j < (signed)E.size() && E[j].p == E[i].p; j++) {
      if (E[j].op == 1) {
        cur.insert(E[j].id);
      } else if (E[j].op == -1) {
        cur.erase(cur.find(E[j].id));
      }
    }
    int len = ((j == (signed)E.size()) ? (inf >> 1) : (E[j].p - E[i].p));
    if (!cur.size()) {
      st.push_back(E[i].p + len);
      fr.push_back(freelen + (blank += len));
    } else if (cur.size() == 1) {
      int x = *cur.begin();
      if (c[x] > C) {
        continue;
      }
      int px = id[x];
      seg.modify(px, -f[x]);
      f[x] += len, g[x] += len;
      int _ = get_position(C - c[x]);
      _ = seg.query(1, _) + f[x];
      g[x] = max(g[x], _);
      seg.modify(px, f[x]);
      int old = freelen;
      freelen = max(f[x], freelen);
      freelen = max(g[x], freelen);
      if (old ^ freelen) {
        st.push_back(E[j].p);
        fr.push_back(freelen + blank);
      }
    } else if (cur.size() == 2) {
      int x = *cur.begin(), y = *--cur.end();
      if (c[x] + c[y] <= C) {
        int com = (G[pii(x, y)] += len);
        int old = freelen;
        g[x] = max(g[x], f[x] + f[y] + com);
        g[y] = max(g[y], f[x] + f[y] + com);
        freelen = max(g[x], freelen);
        freelen = max(g[y], freelen);
        if (old ^ freelen) {
          st.push_back(E[j].p);
          fr.push_back(freelen + blank);
        }
      }
    }
  }
  scanf("%d", &m);
  int x;
  while (m--) {
    scanf("%d", &x);
    int l = 0, r = (signed)fr.size() - 1, mid;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (fr[mid] >= x) {
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    ++r;
    printf("%d\n", st[r] - (fr[r] - x));
  }
  return 0;
}