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