#include <bits/stdc++.h>
using namespace std;
long long ar[2123456], br[2123456];
int main() {
  long long n, m, k, h, l, r, x, ans = 0;
  cin >> n >> h >> m;
  for (int i = 1; i <= n; i++) ar[i] = (h * h);
  while (m--) {
    cin >> l >> r >> x;
    for (int i = l; i <= r; i++) {
      ar[i] = min(ar[i], x * x);
    }
  }
  for (int i = 1; i <= n; i++) {
    ans += ar[i];
  }
  cout << ans;
  return 0;
}
