#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, m;
  cin >> n >> h >> m;
  int a[101] = {0};
  for (int i = 0; i <= 100; i++) a[i] = h;
  while (m--) {
    int x, y, z;
    cin >> x >> y >> z;
    for (int i = x; i <= y; i++) a[i] = min(a[i], z);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) ans += (a[i] * a[i]);
  cout << ans;
  return 0;
}
