#include //ios::sync_with_stdio(false); //cin.tie(0); using namespace std; typedef long long ll; typedef pair pii; typedef pair ppii; typedef pair pipi; typedef pair pll; typedef pair plpl; typedef tuple tl; ll mod=1000000007; ll mod2=998244353; ll inf=1000000000000000000; double pi=2*acos(0); #define rep(i,m,n) for(int i=m;i=m;i--) ll lmax(ll a,ll b){ if(a>n>>m>>a; vector v; ll l[m],r[m],p[m]; rep(i,0,m){ cin>>l[i]>>r[i]>>p[i]; v.push_back(make_pair(l[i],i)); } ll dp[n+3][2]; rep(i,0,n+3){ rep(j,0,2)dp[i][j]=-inf; } int now=0; dp[0][1]=0; rep(i,1,n+1){ dp[i][0]=max(max(dp[i-1][1],dp[i-1][0]),dp[i][0]); while(now