#include <bits/stdc++.h>
using namespace std;
long long x, y, z, m, n, k, t, ar[505];
string s1, s2, s3;
int main() {
  cin >> x >> y >> z;
  for (int i = 1; i <= x; i++) {
    ar[i] = y;
  }
  for (int i = 0; i < z; i++) {
    cin >> n >> m >> k;
    for (int i = n; i <= m; i++) ar[i] = min(ar[i], k);
  }
  for (int i = 1; i <= x; i++) t += ar[i] * ar[i];
  cout << t;
}
