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 = 300005;
int n, C;
struct qq {
  int l, r, c;
} s[N];
struct qt {
  int x, v, id;
  qt(){};
  qt(int _x, int _v, int _id) {
    x = _x;
    v = _v;
    id = _id;
  }
} a[N * 2];
struct qr {
  int id, cost;
} g[N];
bool cmp(qq x, qq y) { return x.c < y.c; }
bool cmp1(qt x, qt y) { return x.x < y.x; }
bool cmp2(qr x, qr y) { return x.cost < y.cost; }
int ans[N];
int m;
set<int>::iterator it;
set<int> S;
map<int, int> cross[N];
int opt[N];
int single[N];
void update(int &x, int y) { x = x > y ? x : y; }
int mymax(int x, int y) { return x > y ? x : y; }
int seg[N * 4];
void change(int now, int l, int r, int x) {
  if (l == r) {
    seg[now] = single[l];
    return;
  }
  int mid = (l + r) >> 1;
  int s1 = now << 1, s2 = s1 | 1;
  if (x <= mid)
    change(s1, l, mid, x);
  else
    change(s2, mid + 1, r, x);
  seg[now] = mymax(seg[s1], seg[s2]);
}
int lx, rx;
int calc(int x, int y) {
  if (x > y) swap(x, y);
  return single[x] + single[y] + cross[x][y];
}
int search(int now, int l, int r) {
  if (l == r) return l;
  int mid = (l + r) >> 1;
  int s1 = now << 1, s2 = s1 | 1;
  if (seg[s1] > seg[s2])
    return search(s1, l, mid);
  else
    return search(s2, mid + 1, r);
}
int get(int now, int l, int r) {
  if (rx < l || lx > r) return 0;
  if (lx <= l && r <= rx) return search(now, l, r);
  int mid = (l + r) >> 1;
  int s1 = now << 1, s2 = s1 | 1;
  int t1 = get(s1, l, mid), t2 = get(s2, mid + 1, r);
  return single[t1] > single[t2] ? t1 : t2;
}
int tot;
void solve() {
  int now, mx;
  now = mx = 0;
  int lst = 0, sum = 0;
  int pos = 0;
  for (int u = 1; u <= tot; u++) {
    int x, y;
    int o = a[u].x - lst;
    lst = a[u].x;
    if (sum == 0)
      now = now + o;
    else if (sum == 1) {
      it = S.begin();
      x = (*it);
      single[x] += o;
      change(1, 1, n, x);
      opt[x] += o;
      int lalal = C - s[x].c;
      if (lalal >= 0) {
        int xx = single[x];
        if (lalal >= s[1].c) {
          int l = 1, r = n;
          while (l <= r) {
            int mid = (l + r) >> 1;
            if (s[mid].c <= lalal)
              l = mid + 1;
            else
              r = mid - 1;
          }
          lx = 1;
          rx = l - 1;
          if (x == rx) rx--;
          if (x < rx) {
            lx = x + 1;
            if (lx <= rx) update(xx, calc(x, get(1, 1, n)));
            lx = 1;
            rx = x - 1;
          }
          if (lx <= rx) update(xx, calc(x, get(1, 1, n)));
        }
        update(opt[x], xx);
        update(mx, opt[x]);
      }
    } else if (sum == 2) {
      it = S.begin();
      x = (*it);
      it++;
      y = (*it);
      cross[x][y] += o;
      if (s[x].c + s[y].c <= C) {
        update(opt[x], calc(x, y));
        update(opt[y], calc(x, y));
        update(mx, opt[x]);
        update(mx, opt[y]);
      }
    }
    while (pos < m && mx + now >= g[pos + 1].cost) {
      pos++;
      ans[g[pos].id] = lst - (mx + now - g[pos].cost);
    }
    if (a[u].v == 1)
      S.insert(a[u].id), sum++;
    else
      S.erase(a[u].id), sum--;
  }
}
int main() {
  scanf("%d%d", &n, &C);
  for (int u = 1; u <= n; u++) scanf("%d%d%d", &s[u].l, &s[u].r, &s[u].c);
  sort(s + 1, s + 1 + n, cmp);
  tot = 0;
  for (int u = 1; u <= n; u++) {
    a[++tot] = qt(s[u].l, 1, u);
    a[++tot] = qt(s[u].r, -1, u);
  }
  a[++tot] = qt(2e9, 1, n + 1);
  sort(a + 1, a + 1 + tot, cmp1);
  scanf("%d", &m);
  for (int u = 1; u <= m; u++) {
    g[u].id = u;
    scanf("%d", &g[u].cost);
  }
  sort(g + 1, g + 1 + m, cmp2);
  solve();
  for (int u = 1; u <= m; u++) printf("%d\n", ans[u]);
  return 0;
}