#include <bits/stdc++.h>
using namespace std;
const long long int M = 1000000007;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
long long int modinver(long long int a, long long int b) {
  return (power(a, 1, M) * power(b, M - 2, M)) % M;
}
void SieveOfEratosthenes(int n) {
  bool prime[10005];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, h, m;
  cin >> n >> h >> m;
  long long int hi[1000];
  for (int i = 1; i <= n; ++i) {
    hi[i] = h;
  }
  for (int i = 0; i < m; ++i) {
    long long int l, r, hr;
    cin >> l >> r >> hr;
    for (int j = l; j <= r; ++j) {
      hi[j] = min(hi[j], hr);
    }
  }
  long long int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += hi[i] * hi[i];
  }
  cout << ans << '\n';
}
