#include <bits/stdc++.h>
using namespace std;
int n, h, m;
int l, r, x;
int ans;
map<int, int> mp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> h >> m;
  for (int i = 1; i <= n; i++) {
    mp[i] = -1;
  }
  for (int i = 0; i < m; ++i) {
    cin >> l >> r >> x;
    for (int i = l; i <= r; ++i) {
      if (mp[i] == -1)
        mp[i] = pow(x, 2);
      else
        mp[i] = pow(x, 2) < mp[i] ? pow(x, 2) : mp[i];
    }
  }
  ans = 0;
  for (int i = 0; i < n; ++i) {
    if (mp[i + 1] != -1) {
      ans += mp[i + 1];
    } else {
      ans += pow(h, 2);
    }
  }
  cout << ans << endl;
  return 0;
}
