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;
int get() {
  char ch;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  if (ch == '-') {
    int s = 0;
    while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
    return -s;
  }
  int s = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
  return s;
}
const int N = 3e5 + 5;
const int INF = 1e9;
int n, C;
struct segment {
  int l, r, c;
} seg[N];
int m;
struct request {
  int k, id;
} qry[N];
int ans[N];
struct addition {
  int x, id;
  addition(const int x_ = 0, const int id_ = 0) {
    x = x_;
    id = id_;
  }
} ad[N * 2];
int u;
int siz[N * 2];
int key[N * 2], k;
set<int> ext;
bool cmp(addition a, addition b) { return a.x < b.x; }
pair<int, int> be[N * 2];
struct section {
  int lef, rig;
} sec[N];
struct node {
  int l, r, val, ad;
} tree[N * 4];
int rt, tot;
int kth[N * 2], s;
map<int, int> id[N];
void build(int &now, int l, int r) {
  now = ++tot;
  if (l == r) {
    tree[now].val = -INF;
    int w = kth[l];
    if (seg[be[w].first].c + seg[be[w].second].c <= C) tree[now].val = 0;
    return;
  }
  int mid = (l + r) / 2;
  build(tree[now].l, l, mid);
  build(tree[now].r, mid + 1, r);
  tree[now].val = max(tree[tree[now].l].val, tree[tree[now].r].val);
}
int val[N], nowv;
int ept;
int kt[N], num[N], Ri[N];
struct node2 {
  int l, r, val;
} tree2[N * 2];
bool cmp1(int x, int y) { return seg[x].c < seg[y].c; }
void prepare() {
  u = 0;
  for (int i = 1; i <= n; i++) {
    ad[++u] = addition(seg[i].l, i);
    ad[++u] = addition(seg[i].r, i);
    num[i] = i;
  }
  sort(num + 1, num + 1 + n, cmp1);
  for (int i = 1; i <= n; i++) kt[num[i]] = i;
  int w = n;
  for (int i = 1; i <= n; i++) {
    int x = num[i];
    while (w && seg[x].c + seg[num[w]].c > C) w--;
    Ri[x] = w;
  }
  for (int i = 1; i <= n; i++) sec[i].lef = INF, sec[i].rig = 0;
  u++;
  ad[u] = addition(0, 0);
  sort(ad + 1, ad + 1 + u, cmp);
  int lst = 0, cnt = 0;
  ext.clear();
  s = 0;
  for (int i = 1; i <= u; i++)
    if (i == u || ad[i].x != ad[i + 1].x) {
      key[++k] = ad[i].x;
      for (int j = lst + 1; j <= i; j++)
        if (ad[j].id) {
          if (seg[ad[j].id].l == ad[i].x)
            ext.insert(ad[j].id), cnt++;
          else
            ext.erase(ad[j].id), cnt--;
        }
      siz[k] = cnt;
      if (cnt == 1) be[k].first = (*ext.begin());
      if (cnt == 2) {
        int x = be[k].first = (*ext.begin());
        set<int>::iterator h = ext.begin();
        h++;
        x = be[k].second = *h;
        if (be[k].first > be[k].second) swap(be[k].first, be[k].second);
        if (!s || be[k].first != be[kth[s]].first ||
            be[k].second != be[kth[s]].second) {
          kth[++s] = k;
          id[be[k].first][be[k].second] = s;
          sec[be[k].first].lef = min(sec[be[k].first].lef, s);
          sec[be[k].first].rig = max(sec[be[k].first].rig, s);
          sec[be[k].second].lef = min(sec[be[k].second].lef, s);
          sec[be[k].second].rig = max(sec[be[k].second].rig, s);
        }
      }
      lst = i;
    }
  nowv = 0;
  for (int i = 1; i <= n; i++)
    if (seg[i].c > C)
      val[i] = -INF;
    else
      val[i] = 0;
  if (s) build(rt, 1, s);
  key[k + 1] = INF * 2 + 5;
  ept = 0;
}
int getw(int x) {
  int l = 1, r = k, ret = k;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (key[mid + 1] > x)
      ret = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  return ret;
}
void down(int now) {
  if (tree[now].ad != 0) {
    int w = tree[now].l;
    tree[w].ad += tree[now].ad;
    tree[w].val += tree[now].ad;
    w = tree[now].r;
    tree[w].ad += tree[now].ad;
    tree[w].val += tree[now].ad;
    tree[now].ad = 0;
  }
}
void change(int now, int l, int r, int x, int y, int v) {
  if (x <= l && r <= y) {
    tree[now].ad = tree[now].ad + v;
    tree[now].val = tree[now].val + v;
    return;
  }
  down(now);
  int mid = (l + r) / 2;
  if (x <= mid) change(tree[now].l, l, mid, x, y, v);
  if (y > mid) change(tree[now].r, mid + 1, r, x, y, v);
  tree[now].val = max(tree[tree[now].l].val, tree[tree[now].r].val);
}
int query(int now, int l, int r, int x, int y) {
  if (x <= l && r <= y) return tree[now].val;
  down(now);
  int mid = (l + r) / 2;
  int ret = -INF;
  if (x <= mid) ret = query(tree[now].l, l, mid, x, y);
  if (y > mid) ret = max(ret, query(tree[now].r, mid + 1, r, x, y));
  return ret;
}
void change2(int now, int l, int r, int x, int v) {
  if (l == r) {
    tree2[now].val = v;
    return;
  }
  int mid = (l + r) / 2;
  int ls = now + 1, rs = now + (mid - l + 1) * 2;
  if (x <= mid)
    change2(ls, l, mid, x, v);
  else
    change2(rs, mid + 1, r, x, v);
  tree2[now].val = max(tree2[ls].val, tree2[rs].val);
}
int query2(int now, int l, int r, int x, int y) {
  if (x <= l && r <= y) return tree2[now].val;
  int mid = (l + r) / 2;
  int ls = now + 1, rs = now + (mid - l + 1) * 2;
  int ret = -INF;
  if (x <= mid) ret = query2(ls, l, mid, x, y);
  if (y > mid) ret = max(ret, query2(rs, mid + 1, r, x, y));
  return ret;
}
bool cmp2(request a, request b) { return a.k < b.k; }
void solve() {
  sort(qry + 1, qry + 1 + m, cmp2);
  int w = 1;
  for (int i = 1; i <= k; i++) {
    if (siz[i] > 2) continue;
    int Len = key[i + 1] - key[i];
    if (siz[i] == 0) {
      while (w <= m && qry[w].k - nowv <= Len) {
        ans[qry[w].id] = key[i] + qry[w].k - nowv;
        w++;
      }
      ept += Len;
      nowv = nowv + Len;
    }
    if (siz[i] == 1) {
      int x = be[i].first;
      int mx = val[x];
      if (Ri[x]) {
        if (Ri[x] >= kt[x]) {
          if (kt[x] > 1) mx = max(mx, query2(1, 1, n, 1, kt[x] - 1) + val[x]);
          if (kt[x] < Ri[x])
            mx = max(mx, query2(1, 1, n, kt[x] + 1, Ri[x]) + val[x]);
        } else
          mx = max(mx, query2(1, 1, n, 1, Ri[x]) + val[x]);
      }
      val[x] += Len;
      change2(1, 1, n, kt[x], val[x]);
      if (sec[x].lef <= sec[x].rig) {
        mx = max(mx, query(rt, 1, s, sec[x].lef, sec[x].rig));
        change(rt, 1, s, sec[x].lef, sec[x].rig, Len);
      }
      mx = mx + ept;
      while (w <= m && qry[w].k <= (long long)mx + Len) {
        ans[qry[w].id] = key[i] + qry[w].k - mx;
        w++;
      }
      nowv = max(nowv, mx + Len);
    }
    if (siz[i] == 2) {
      int x = be[i].first, y = be[i].second;
      int mx = ept + query(rt, 1, s, id[x][y], id[x][y]);
      change(rt, 1, s, id[x][y], id[x][y], Len);
      while (w <= m && qry[w].k <= (long long)mx + Len) {
        ans[qry[w].id] = key[i] + qry[w].k - mx;
        w++;
      }
      nowv = max(nowv, mx + Len);
    }
  }
}
int main() {
  n = get();
  C = get();
  for (int i = 1; i <= n; i++) {
    seg[i].l = get();
    seg[i].r = get();
    seg[i].c = get();
  }
  m = get();
  for (int i = 1; i <= m; i++) {
    qry[i].k = get();
    qry[i].id = i;
  }
  prepare();
  solve();
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}