#include <bits/stdc++.h>
using namespace std;
void gn(int &x) {
  x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
int n, p, q, r;
int a[500010], b[500010], c[500010];
int x[500010], y[500010], h[500010];
long long sum[500010];
int top;
long long ans;
long long calc(int x, int y) {
  int l = p - x, r = lower_bound(h + 1, h + p + 1, y) - h - 1;
  if (r <= l) return 1ll * x * y;
  return 1ll * y * (p - r) + sum[r] - sum[l];
}
int main() {
  gn(n);
  gn(p);
  gn(q);
  gn(r);
  for (int i = 1; i <= r; ++i) x[i] = p, y[i] = q;
  for (int i = 1; i <= p; ++i) h[i] = q;
  for (int i = 1; i <= n; ++i) {
    gn(a[i]);
    gn(b[i]);
    gn(c[i]);
    h[a[i]] = min(h[a[i]], q - b[i]);
    x[c[i]] = min(x[c[i]], p - a[i]);
    y[c[i]] = min(y[c[i]], q - b[i]);
  }
  for (int i = r; i > 1; --i) {
    x[i - 1] = min(x[i - 1], x[i]);
    y[i - 1] = min(y[i - 1], y[i]);
  }
  for (int i = p; i > 1; --i) h[i - 1] = min(h[i - 1], h[i]);
  for (int i = 1; i <= p; ++i) sum[i] = sum[i - 1] + h[i];
  for (int i = 1; i <= r; ++i) ans += calc(x[i], y[i]);
  printf("%I64d\n", ans);
  return 0;
}
