#include <bits/stdc++.h>
using namespace std;
int L[50];
int r[50];
int x[50];
int h;
int n;
int m;
int test;
int t2;
int main() {
  cin >> n >> h >> m;
  for (int i = 0; i < m; i++) cin >> L[i] >> r[i] >> x[i];
  long long res = 0;
  int mx;
  for (int i = 1; i <= n; i++) {
    mx = 0;
    test = 1;
    t2 = 1;
    for (int j = 0; j < m; j++) {
      if (i >= L[j] && i <= r[j]) {
        t2 = 0;
        if (test) {
          mx = x[j] * x[j];
          test = 0;
        } else
          mx = min(mx, x[j] * x[j]);
      }
    }
    if (t2) mx = h * h;
    res += mx;
  }
  cout << res;
  return 0;
}
