#include <bits/stdc++.h>
using namespace std;
int n, h, m, f[55][55][55], c[55][55][55];
struct P {
  int l, r, x, c;
} p[55];
inline int max(int a, int b, int c) {
  if (a < b) a = b;
  if (a < c) a = c;
  return a;
}
int dfs(int l, int r, int w) {
  if (l > r && w == 0) return 0;
  if (f[l][r][w] != 0) return f[l][r][w];
  for (int i = l; i <= r; i++) {
    for (int j = 1; j <= h; j++) c[l][r][j] = 0;
    for (int j = 1; j <= m; j++)
      if (l <= p[j].l && p[j].r <= r && p[j].l <= i && i <= p[j].r)
        c[l][r][p[j].x + 1] += p[j].c;
    for (int j = 1; j <= w; j++) {
      c[l][r][j] += c[l][r][j - 1];
      f[l][r][j] =
          max(f[l][r][j], f[l][r][j - 1],
              dfs(l, i - 1, j) + dfs(i + 1, r, j) + j * j - c[l][r][j]);
    }
  }
  return f[l][r][w];
}
int main() {
  scanf("%d%d%d", &n, &h, &m);
  for (int i = 1; i <= m; i++)
    scanf("%d%d%d%d", &p[i].l, &p[i].r, &p[i].x, &p[i].c);
  printf("%d", dfs(1, n, h));
  return 0;
}
