#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int arr[maxn];
int main() {
  int n, m, h, l, r, x;
  cin >> n >> h >> m;
  for (int i = 0; i < n; i++) arr[i] = h;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> x;
    for (int j = l - 1; j < r; j++) arr[j] = min(x, arr[j]);
  }
  unsigned long long ans = 0;
  for (int i = 0; i < n; i++) ans += arr[i] * arr[i];
  cout << ans;
  return 0;
}
