#include <bits/stdc++.h>
using namespace std;
int read() {
  int xx = 0, ff = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    xx = xx * 10 + ch - '0';
    ch = getchar();
  }
  return xx * ff;
}
long long READ() {
  long long xx = 0, ff = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    xx = xx * 10 + ch - '0';
    ch = getchar();
  }
  return xx * ff;
}
char one() {
  char ch = getchar();
  while (ch == ' ' || ch == '\n') ch = getchar();
  return ch;
}
int N, H, M;
int a[55];
int main() {
  N = read(), H = read(), M = read();
  for (int i = 1; i <= N; i++) a[i] = H;
  for (int i = 1; i <= M; i++) {
    int L = read(), R = read(), t = read();
    for (int j = L; j <= R; j++) a[j] = min(a[j], t);
  }
  long long ans = 0;
  for (int i = 1; i <= N; i++) ans += 1LL * a[i] * a[i];
  cout << ans << endl;
  return 0;
}
