int f[maxn][maxn], g[maxn][maxn][maxn]; intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
cin >> n >> m; for (int i = 1; i <= m; ++i) { int x, y, z; cin >> z >> x >> y; for (int j = x; j <= y; ++j) g[j][x][y] = z; } for (int len = 1; len <= n; ++len) for (int i = 1, j = len; j <= n; ++i, ++j) for (int k = i; k <= j; ++k) g[k][i][j] = max({ g[k][i][j], g[k][i + 1][j], g[k][i][j - 1] }); for (int len = 1; len <= n; ++len) for (int i = 1, j = len; j <= n; ++i, ++j) for (int k = i; k <= j; ++k) f[i][j] = max(f[i][j], f[i][k - 1] + f[k + 1][j] + g[k][i][j]); cout << f[1][n] << "\n"; return0; }