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 = 6e5 + 10, MOD = 1e9 + 7, SQ = 500;
int c[N], l[N], r[N];
int ans[N];
int cnt[N], cnt2[N];
vector<pair<int, int>> adj[N], adj2[N];
map<pair<int, int>, int> id;
int mxx[N];
int seg_max[4 * N];
void upd(int i, int val, int s = 0, int e = N, int ind = 1) {
  if (e - s == 1) {
    seg_max[ind] = val;
    return;
  }
  int mid = (s + e) / 2;
  if (i < mid)
    upd(i, val, s, mid, 2 * ind);
  else
    upd(i, val, mid, e, 2 * ind + 1);
  seg_max[ind] = max(seg_max[2 * ind], seg_max[2 * ind + 1]);
}
int get_max(int l, int r, int s = 0, int e = N, int ind = 1) {
  if (l <= s && e <= r) return seg_max[ind];
  if (r <= s || e <= l) return 0;
  int mid = (s + e) / 2;
  return max(get_max(l, r, s, mid, 2 * ind),
             get_max(l, r, mid, e, 2 * ind + 1));
}
multiset<int> value[N];
int c2[N];
vector<int> to_add[N], to_rem[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, C;
  vector<int> vx, vc;
  cin >> n >> C;
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i] >> c[i];
    vx.push_back(l[i]);
    vx.push_back(r[i]);
    vc.push_back(c[i]);
  }
  vx.push_back(0);
  vx.push_back(2e9 + 10);
  sort(vx.begin(), vx.end());
  vx.resize(unique(vx.begin(), vx.end()) - vx.begin());
  sort(vc.begin(), vc.end());
  vc.resize(unique(vc.begin(), vc.end()) - vc.begin());
  for (int i = 0; i < n; i++) {
    l[i] = lower_bound(vx.begin(), vx.end(), l[i]) - vx.begin();
    r[i] = lower_bound(vx.begin(), vx.end(), r[i]) - vx.begin();
    c2[i] = lower_bound(vc.begin(), vc.end(), c[i]) - vc.begin();
    value[c2[i]].insert(0);
    value[c2[i]].insert(0);
    to_add[l[i]].push_back(i);
    to_rem[r[i]].push_back(i);
  }
  int q;
  cin >> q;
  set<pair<int, int>> s;
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    s.insert({x, i});
  }
  int m = vx.size(), xx = 1;
  set<int> ss;
  for (int i = 0; i < m; i++) {
    for (auto u : to_add[i]) ss.insert(u);
    for (auto u : to_rem[i]) ss.erase(u);
    vector<int> v;
    while (v.size() < 3 && ss.size()) {
      v.push_back(*ss.begin());
      ss.erase(ss.begin());
    }
    for (auto u : v) ss.insert(u);
    if (v.size() == 2) {
      int x = v[0], y = v[1];
      if (!id[make_pair(x, y)] && c[x] + c[y] <= C) {
        id[make_pair(x, y)] = id[make_pair(y, x)] = xx++;
        adj[x].push_back({y, xx - 1});
        adj[y].push_back({x, xx - 1});
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (auto u : adj[i])
      if (adj[u.first].size() > SQ) adj2[i].push_back(u);
  }
  int mx = 0;
  int sum = 0;
  ss.clear();
  for (int i = 0; i < m - 1; i++) {
    for (auto u : to_add[i]) ss.insert(u);
    for (auto u : to_rem[i]) ss.erase(u);
    vector<int> v;
    while (v.size() < 3 && ss.size()) {
      v.push_back(*ss.begin());
      ss.erase(ss.begin());
    }
    for (auto u : v) ss.insert(u);
    int len = vx[i + 1] - vx[i];
    if (!v.size()) sum += len;
    if (v.size() == 1) {
      int x = v[0];
      value[c2[x]].erase(value[c2[x]].find(cnt[x]));
      cnt[x] += len;
      value[c2[x]].insert(cnt[x]);
      if (c[x] <= C) {
        mx = max(mx, cnt[x]);
        value[c2[x]].erase(value[c2[x]].find(cnt[x]));
        upd(c2[x], *value[c2[x]].rbegin());
        int j = upper_bound(vc.begin(), vc.end(), C - c[x]) - vc.begin();
        mx = max(mx, cnt[x] + get_max(0, j));
        value[c2[x]].insert(cnt[x]);
      }
      upd(c2[x], *value[c2[x]].rbegin());
      for (auto u : adj2[x])
        mx = max(mx, cnt[x] + cnt[u.first] + cnt2[u.second]);
      if (c[x] <= C) mx = max(mx, mxx[x] + cnt[x]);
      if (adj[x].size() <= SQ) {
        for (auto u : adj[x])
          mxx[u.first] = max(mxx[u.first], cnt[x] + cnt2[u.second]);
      }
    }
    if (v.size() == 2) {
      int ind = id[make_pair(v[0], v[1])];
      cnt2[ind] += len;
      if (c[v[0]] + c[v[1]] <= C) {
        mx = max(mx, cnt[v[0]] + cnt[v[1]] + cnt2[ind]);
        mxx[v[0]] = max(mxx[v[0]], cnt2[ind] + cnt[v[1]]);
        mxx[v[1]] = max(mxx[v[1]], cnt2[ind] + cnt[v[0]]);
      }
    }
    while (s.size() && mx + sum >= s.begin()->first) {
      ans[s.begin()->second] =
          vx[i + 1] - 1 - (-(s.begin()->first) + (sum + mx));
      s.erase(s.begin());
    }
  }
  for (int i = 0; i < q; i++) cout << ans[i] + 1 << '\n';
}