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 = 1e6 + 50, M = 3e5 + 50;
int gi() {
  char ch = getchar();
  int x = 0, q = 0;
  while (ch < '0' || ch > '9') q = ch == '-' ? 1 : q, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return q ? -x : x;
}
int n, m, C, a[N], b[N], c[N], w[N], rk[N], tr[N * 2], tot, S, siz, fre, sum;
int val[N], Ans[N], ano[N], sa[N];
struct data {
  int s, t;
  bool operator<(const data &b) const { return s < b.s; }
} v[N], q[N], g[N];
map<int, int> f[M];
set<int> ID;
void update(int x) {
  tr[x] = (tr[(x << 1)] > tr[(x << 1 | 1)] ? tr[(x << 1)] : tr[(x << 1 | 1)]);
  return;
}
void add(int x, int l, int r, int y, int s) {
  if (l == r) {
    val[l] += s, tr[x] += s;
    return;
  }
  int mid = (l + r) >> 1;
  if (y <= mid)
    add((x << 1), l, mid, y, s);
  else
    add((x << 1 | 1), mid + 1, r, y, s);
  return update(x);
}
int query(int x, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return tr[x];
  int mid = (l + r) >> 1, tmp, ans = 0;
  if (ql <= mid)
    tmp = query((x << 1), l, mid, ql, qr), ans = (ans > tmp ? ans : tmp);
  if (qr > mid)
    tmp = query((x << 1 | 1), mid + 1, r, ql, qr),
    ans = (ans > tmp ? ans : tmp);
  return ans;
}
void calc(int x) {
  if (v[x].s > C) return;
  sum = (sum > val[x] + ano[sa[x]] ? sum : val[x] + ano[sa[x]]);
  int id = upper_bound(v + 1, v + n + 1, (data){C - v[x].s}) - v - 1, tmp;
  if (!id) return;
  if (id < x) {
    tmp = query(1, 1, n, 1, id);
    sum = (sum > tmp + val[x] ? sum : tmp + val[x]);
  } else {
    if (x > 1) {
      tmp = query(1, 1, n, 1, x - 1);
      sum = (sum > tmp + val[x] ? sum : tmp + val[x]);
    }
    if (id > x) {
      tmp = query(1, 1, n, x + 1, id);
      sum = (sum > tmp + val[x] ? sum : tmp + val[x]);
    }
  }
  return;
}
void cal(int x, int y) {
  if (v[rk[x]].s + v[rk[y]].s > C) return;
  int s = f[x][y];
  ano[x] = (ano[x] > s + val[rk[y]] ? ano[x] : s + val[rk[y]]);
  ano[y] = (ano[y] > s + val[rk[x]] ? ano[y] : s + val[rk[x]]);
  sum = (sum > val[rk[x]] + val[rk[y]] + s ? sum : val[rk[x]] + val[rk[y]] + s);
  return;
}
int main() {
  cin >> n >> C;
  for (int i = 1; i <= n; ++i) {
    a[i] = gi(), b[i] = gi(), c[i] = gi();
    v[i] = (data){c[i], i};
    g[++tot] = (data){a[i], i};
    g[++tot] = (data){b[i], i};
  }
  sort(v + 1, v + n + 1);
  for (int i = 1; i <= n; ++i) rk[v[i].t] = i, sa[i] = v[i].t;
  sort(g + 1, g + tot + 1);
  cin >> m;
  for (int i = 1; i <= m; ++i) q[i] = (data){gi(), i};
  sort(q + 1, q + m + 1);
  int las = 0, s, x, tt = 1;
  for (int i = 1; i <= tot; ++i) {
    s = g[i].s - las, las = g[i].s;
    if (w[g[i].t]) {
      S ^= g[i].t, --siz;
      if (siz == 0)
        add(1, 1, n, rk[g[i].t], s), calc(rk[g[i].t]);
      else if (siz == 1)
        f[g[i].t][S] += s, f[S][g[i].t] += s, cal(g[i].t, S);
      ID.erase(g[i].t);
    } else {
      ++siz;
      if (siz == 1)
        fre += s;
      else if (siz == 2)
        add(1, 1, n, rk[S], s), calc(rk[S]);
      else if (siz == 3)
        x = *ID.begin(), f[x][S ^ x] += s, f[S ^ x][x] += s, cal(S ^ x, x);
      ID.insert(g[i].t);
      S ^= g[i].t, w[g[i].t] = 1;
    }
    while (tt <= m && fre + sum >= q[tt].s)
      Ans[q[tt].t] = las - fre - sum + q[tt].s, ++tt;
  }
  while (tt <= m) Ans[q[tt].t] = las + q[tt].s - fre - sum, ++tt;
  for (int i = 1; i <= m; ++i) printf("%d\n", Ans[i]);
  return 0;
}