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