#include using namespace std; using ll=long long; #include using namespace atcoder; using mint=modint998244353; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll N,Y,Z; cin>>N>>Y>>Z; vector> P(N); for(int i=0;i>P[i][0]>>P[i][1]>>P[i][2]; } vector> EV(N+2); for(int i=0;i> Q; while(cn<=N+1&&EV[cn][0]<=Y){ int id=EV[cn][1]; if(id!=-1){ Q.push({P[id][2],P[id][0]}); } cn++; } while(Y0&&tim>nm){ an+=nm; Y+=v*nm; continue; } else{ if(nm>tim)Q.push({v,nm-tim}); Y+=v*tim; an+=tim; int id=EV[cn][1]; if(id!=-1){ Q.push({P[id][2],P[id][0]}); } cn++; } } cout<