#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, h, m;
  cin >> n >> h >> m;
  int l, r, x;
  vector<int> v;
  v.assign(n, h * h);
  while (m--) {
    cin >> l >> r >> x;
    for (int i = l - 1; i < r; ++i) {
      v[i] = min(v[i], x * x);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) ans += v[i];
  cout << ans << endl;
  return 0;
}
