#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, m, l, r, x, sum = 0;
  cin >> n >> h >> m;
  int a[n + 1];
  for (int i = 1; i <= n; i++) a[i] = -1;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> x;
    for (int i = l; i <= r; i++) {
      if (a[i] == -1)
        a[i] = x;
      else if (a[i] > x)
        a[i] = x;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == -1)
      sum += (h * h);
    else
      sum += (a[i] * a[i]);
  }
  cout << sum << endl;
}
