#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
const int maxn = 5e1 + 10, maxm = 1e5 + 10, lg = 23, mod = 1e9 + 7, inf = 1e18;
int n, h, m, dp[maxn][maxn][maxn];
int L[maxn], R[maxn], X[maxn], C[maxn];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> h >> m;
  for (int i = 0; i < m; i++) cin >> L[i] >> R[i] >> X[i] >> C[i];
  for (int i = 1; i <= h; i++)
    for (int len = 1; len <= n; len++)
      for (int l = 1, r; l + len - 1 <= n; l++) {
        r = l + len - 1;
        dp[i][l][r] = dp[i - 1][l][r];
        for (int j = l; j <= r; j++) {
          int sud = i * i;
          for (int k = 0; k < m; k++)
            if (l <= L[k] && r >= R[k] && L[k] <= j && j <= R[k] && X[k] < i)
              sud -= C[k];
          dp[i][l][r] =
              max(dp[i][l][r], dp[i][l][j - 1] + dp[i][j + 1][r] + sud);
        }
      }
  cout << dp[h][1][n];
  return 0;
}
