#include <bits/stdc++.h>
using namespace std;
int a[101];
int main() {
  int n, h, m, i, j;
  int l, r, maxn;
  scanf("%d%d%d", &n, &h, &m);
  for (i = 1; i <= n; i++) {
    a[i] = h;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &l, &r, &maxn);
    for (j = l; j <= r; j++) {
      a[j] = min(a[j], maxn);
    }
  }
  int sum = 0;
  for (i = n; i >= 1; i--) {
    sum += a[i] * a[i];
  }
  cout << sum << endl;
  return 0;
}
