#include using namespace std; typedef long long ll; signed main(){ //cout << setprecision(12) ; ios::sync_with_stdio(false); cin.tie(0); ll n,m,a; cin>>n>>m>>a; vector>> v(111111); for(ll i=0;i>l>>r>>c; l--; v[r].push_back(make_pair(l,c)); } vector dp(n+1,-a); dp[0]=0,dp[n]=0; ll ans=0; for(ll i=0;i<=n;i++){ ll ret=0; for(auto j:v[i]){ ret = max(ret,dp[j.first]+j.second); } dp[i] += ret; ans = max(ans,dp[i]); dp[i] = max(ans,dp[i]); } cout<