#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> ans;
vector<pair<ll,pair<ll,ll>>> a;
vector<ll> M;
int cnt;
ll t;
int n;
void sol(ll l, ll h, int lt, int rt){
if(lt>rt)return;
if(l==h){
for(int j=lt;j<=rt;j++)ans[j]=l;
return;
}
ll m=(l+h+1)/2;
priority_queue<pair<ll,int>> pq;
pq.push({a[0].second.first,a[0].second.second*m});
for(int i=1;i<=n;i++){
ll cur=t-a[i-1].first;
if(i!=n)cur=a[i].first-a[i-1].first;
while(cur>0){
auto [p,x]=pq.top();
pq.pop();
if(x==0)break;
if(x>=cur){
pq.push({p,x-cur});
break;
}
cur-=x;
}
if(i!=n){
pq.push({a[i].second.first,a[i].second.second*m});
}
}
ll rem=0;
while(!pq.empty()){
auto [p,x]=pq.top();
rem+=p*x;
pq.pop();
}
int id=lower_bound(M.begin(),M.end(),rem)-M.begin();
sol(m,h,id,rt);
sol(l,m-1,lt,id-1);
return;
}
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
ll L;
cin >> n >> L >> t;
a.resize(n);
for(int i=0;i<n;i++){
cin >> a[i].first >> a[i].second.second >> a[i].second.first;
}
sort(a.begin(),a.end());
cnt=0;
int q;
cin >> q;
M.resize(q);
ans.resize(q);
for(int i=0;i<q;i++)cin >> M[i];
sol(0,L,0,q-1);
for(auto i:ans)cout << i<< "\n";
}