#include <bits/stdc++.h>
using namespace std;
long long int INF = 10000000000;
long long int MOD = 1000000000 + 7;
int main() {
  long long int i, n, h, m;
  cin >> n >> h >> m;
  vector<long long int> v(n + 10);
  for (i = 1; i <= n; i++) {
    v[i] = h;
  }
  while (m--) {
    long long int l, r, x;
    cin >> l >> r >> x;
    for (i = l; i <= r; i++) {
      v[i] = min(v[i], x);
    }
  }
  long long int ans = 0;
  for (i = 1; i <= n; i++) {
    ans += v[i] * v[i];
  }
  cout << ans << endl;
}
