#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e18;
const long long int mod = 1e9 + 7;
const long long int MOD = 998244353;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
vector<char *> tokenizer(const char *args) {
  char *token = new char[111];
  strcpy(token, args);
  token = strtok(token, ", ");
  vector<char *> v({token});
  while ((token = strtok(NULL, ", "))) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void debugg(vector<char *> args) { cerr << "\b\b "; }
#pragma clang diagnostic pop
template <typename Head, typename... Tail>
void debugg(vector<char *> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back();
  debugg(args, T...);
}
template <typename T>
T power(T a, T b) {
  if (b == 0) return 1;
  if (b == 1)
    return a;
  else {
    T res = (power(a, b / 2));
    if (b % 2) {
      return (res * res * a);
    } else {
      return res * res;
    }
  }
}
template <typename T>
T power(T a, T b, T modulo) {
  if (b == 0) return 1;
  if (b == 1)
    return a;
  else {
    T res = (power(a, b / 2, modulo) % modulo);
    if (b % 2) {
      return ((((res % modulo) * (res % modulo)) % modulo) * (a % modulo)) %
             modulo;
    } else {
      return ((res % modulo) * (res % modulo)) % modulo;
    }
  }
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
template <typename T>
T gcd_extended(T a, T b, T &x, T &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  T x1, y1;
  T d = gcd_extended(b, a % b, x1, y1);
  x = y1;
  y = x1 - y1 * (a / b);
  return d;
}
bool find_solution(long long int a, long long int b, long long int c,
                   long long int &x, long long int &y) {
  long long int g = gcd_extended<long long int>(a, b, x, y);
  if (c % g) {
    return false;
  }
  x = x * (c / g);
  y = y * (c / g);
  if (a < 0) x *= (-1);
  if (b < 0) y *= (-1);
  return true;
}
void factorial(vector<long long int> &fact, long long int n) {
  fact.resize(n + 1, 1);
  fact[0] = 1;
  fact[1] = 1;
  for (int i = 2; i <= n; ++i) {
    fact[i] = ((fact[i - 1] % mod) * (i % mod)) % mod;
  }
}
long long int mod_inv(long long int a) {
  return (power<long long int>(a, mod - 2, mod)) % mod;
}
long long int ncr(long long int n, long long int r,
                  vector<long long int> &fact) {
  if (r > n or n < 0 or r < 0) return 0LL;
  return (((fact[n] % mod) * (mod_inv(fact[n - r]) % mod)) % mod *
          (mod_inv(fact[r]) % mod)) %
         mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int n, h, m;
  cin >> n >> h >> m;
  vector<long long int> ans(n + 1, h);
  for (int i = 0; i < m; ++i) {
    long long int l, r;
    cin >> l >> r;
    long long int x;
    cin >> x;
    for (int j = l; j <= r; ++j) {
      ans[j] = min(ans[j], x);
    }
  }
  long long int a = 0;
  for (int i = 1; i <= n; ++i) {
    a += ans[i] * ans[i];
  }
  cout << ((a)) << "\n";
  ;
  return 0;
}
