#include <bits/stdc++.h>
using namespace std;
int h, i, l, m, n, r, s, x, e[51];
int main() {
  scanf("%d%d%d", &n, &h, &m);
  for (; i++ < n;) e[i] = h;
  for (; m--;)
    for (scanf("%d%d%d", &l, &r, &x); l <= r; l++) e[l] = e[l] < x ? e[l] : x;
  for (i = 0; i++ < n;) s += e[i] * e[i];
  printf("%d", s);
}
