#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> st;
void upd(int v, int tl, int tr, int pos, ll val){
if(tl==tr)st[v]+=val;
else{
int tm=(tl+tr)/2;
if(pos<=tm)upd(v*2,tl,tm,pos,val);
else upd(v*2+1,tm+1,tr,pos,val);
st[v]=st[v*2]+st[v*2+1];
}
}
pair<ll,int> wk(int v, int tl, int tr){
if(st[v]==0)return {0,-1};
if(tl==tr)return {st[v],tl};
int tm=(tl+tr)/2;
if(st[v*2+1])return wk(v*2+1,tm+1,tr);
return wk(v*2,tl,tm);
}
ll gt(int v, int tl, int tr, int pos){
if(tl==tr)return st[v];
int tm=(tl+tr)/2;
if(tm>=pos)return gt(v*2,tl,tm,pos);
else return gt(v*2+1,tm+1,tr,pos);
}
vector<ll> ans;
vector<pair<ll,pair<ll,ll>>> a;
map<ll,ll> mp;
vector<ll> val;
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;
}
if(lt==rt){
while(l<h){
ll m=(l+h+1)/2;
st.clear();
st.resize(4*cnt);
upd(1,0,cnt-1,mp[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 [x,p]=wk(1,0,cnt-1);
if(x==0)break;
if(x>=cur){
upd(1,0,cnt-1,p,-(cur));
break;
}
upd(1,0,cnt-1,p,-x);
cur-=x;
}
if(i!=n)upd(1,0,cnt-1,mp[a[i].second.first],a[i].second.second*m);
}
ll rem=0;
for(int i=0;i<cnt;i++) rem+=gt(1,0,cnt-1,i)*val[i];
if(rem<=M[lt])l=m;
else h=m-1;
}
ans[lt]=l;
return;
}
ll m=(l+h+1)/2;
st.clear();
st.resize(4*cnt);
upd(1,0,cnt-1,mp[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 [x,p]=wk(1,0,cnt-1);
if(x==0)break;
if(x>=cur){
upd(1,0,cnt-1,p,-(cur));
break;
}
upd(1,0,cnt-1,p,-x);
cur-=x;
}
if(i!=n)upd(1,0,cnt-1,mp[a[i].second.first],a[i].second.second*m);
}
ll rem=0;
for(int i=0;i<cnt;i++) rem+=gt(1,0,cnt-1,i)*val[i];
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;
if(mp[a[i].second.first]==0)val.push_back(a[i].second.first);
mp[a[i].second.first]++;
}
sort(val.begin(),val.end());
sort(a.begin(),a.end());
cnt=0;
for(auto& i:mp){
i.second=cnt;
cnt++;
}
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);
/*ll prev=0;
for(int i=0;i<q;i++){
ll l=prev;
ll h=L;
while(l<h){
ll m=(l+h+1)/2;
st.clear();
st.resize(4*cnt);
upd(1,0,cnt-1,mp[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 [x,p]=wk(1,0,cnt-1);
if(x==0)break;
if(x>=cur){
upd(1,0,cnt-1,p,-(cur));
break;
}
upd(1,0,cnt-1,p,-x);
cur-=x;
}
if(i!=n)upd(1,0,cnt-1,mp[a[i].second.first],a[i].second.second*m);
}
ll rem=0;
for(int i=0;i<cnt;i++) rem+=gt(1,0,cnt-1,i)*val[i];
if(rem<=M[i])l=m;
else h=m-1;
}
cout << l << "\n";
}*/
for(auto i:ans)cout << i<< "\n";
}