#include <bits/stdc++.h>
using namespace std;
int a[1000];
int main() {
  int n, m, h, c, d, e;
  cin >> n >> h >> m;
  for (int i = 1; i <= n; i++) {
    a[i] = h;
  }
  for (int i = 1; i <= m; i++) {
    cin >> c >> d >> e;
    for (int i = c; i <= d; i++) {
      if (a[i] > e) a[i] = e;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (a[i] * a[i]);
  }
  cout << ans << endl;
}
