#include <bits/stdc++.h>
using namespace std;
int n, h, m, l, r, x, xam[105];
int main() {
  scanf("%d %d %d", &n, &h, &m);
  for (int i = 1; i <= n; i++) xam[i] = h;
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &l, &r, &x);
    for (int j = l; j <= r; j++) {
      xam[j] = min(xam[j], x);
    }
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    res += xam[i] * xam[i];
  }
  printf("%lld\n", res);
}
