#include <bits/stdc++.h>
using namespace std;
const int N = 500005, M = 1311000;
int n, p, q, r, Ma[N], Mb[N], Tag[M], Mx[M], tmp;
long long ans, sum[M], s;
struct Data {
  int a, b, c;
} A[N];
char c;
int read() {
  int x = 0, sig = 1;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48;
  return x * sig;
}
bool operator<(const Data &a, const Data &b) { return a.c < b.c; }
void Ins(int l, int r, int a, int b, int v, int x) {
  if (l == a && r == b) {
    Tag[x] = Mx[x] = v;
    sum[x] = (long long)(r - l + 1) * v;
    return;
  }
  int mid = l + r >> 1;
  if (Tag[x] > 0) {
    Tag[x << 1] = Tag[x << 1 | 1] = Mx[x << 1] = Mx[x << 1 | 1] = Tag[x];
    sum[x << 1] = (long long)(mid - l + 1) * Tag[x];
    sum[x << 1 | 1] = (long long)(r - mid) * Tag[x];
    Tag[x] = 0;
  }
  if (b <= mid)
    Ins(l, mid, a, b, v, x << 1);
  else if (a > mid)
    Ins(mid + 1, r, a, b, v, x << 1 | 1);
  else {
    Ins(l, mid, a, mid, v, x << 1);
    Ins(mid + 1, r, mid + 1, b, v, x << 1 | 1);
  }
  sum[x] = sum[x << 1] + sum[x << 1 | 1];
  Mx[x] = ((Mx[x << 1]) > (Mx[x << 1 | 1]) ? (Mx[x << 1]) : (Mx[x << 1 | 1]));
}
void Get(int l, int r, int g, int x) {
  if (l == r) {
    tmp = l;
    return;
  }
  int mid = l + r >> 1;
  if (Tag[x] > 0) {
    Tag[x << 1] = Tag[x << 1 | 1] = Mx[x << 1] = Mx[x << 1 | 1] = Tag[x];
    sum[x << 1] = (long long)(mid - l + 1) * Tag[x];
    sum[x << 1 | 1] = (long long)(r - mid) * Tag[x];
    Tag[x] = 0;
  }
  if (Mx[x << 1 | 1] < g)
    Get(l, mid, g, x << 1);
  else
    Get(mid + 1, r, g, x << 1 | 1);
}
void getsum(int l, int r, int a, int b, int x) {
  if (l == a && r == b) {
    s += sum[x];
    return;
  }
  int mid = l + r >> 1;
  if (Tag[x] > 0) {
    Tag[x << 1] = Tag[x << 1 | 1] = Mx[x << 1] = Mx[x << 1 | 1] = Tag[x];
    sum[x << 1] = (long long)(mid - l + 1) * Tag[x];
    sum[x << 1 | 1] = (long long)(r - mid) * Tag[x];
    Tag[x] = 0;
  }
  if (b <= mid)
    getsum(l, mid, a, b, x << 1);
  else if (a > mid)
    getsum(mid + 1, r, a, b, x << 1 | 1);
  else {
    getsum(l, mid, a, mid, x << 1);
    getsum(mid + 1, r, mid + 1, b, x << 1 | 1);
  }
}
int main() {
  n = read();
  p = read();
  q = read();
  r = read();
  for (int i = 1; i <= n; i++) {
    A[i].a = read();
    A[i].b = read();
    A[i].c = read();
  }
  sort(A + 1, A + n + 1);
  for (int i = n; i; i--) {
    Ma[i] = ((Ma[i + 1]) > (A[i].a) ? (Ma[i + 1]) : (A[i].a));
    Mb[i] = ((Mb[i + 1]) > (A[i].b) ? (Mb[i + 1]) : (A[i].b));
  }
  Ins(0, p, 0, 0, q + 1, 1);
  for (int i = 1, j = 1, k; i <= r; i++) {
    for (; j <= n && A[j].c < i; j++) {
      Get(0, p, A[j].b, 1);
      if (tmp >= A[j].a) continue;
      Ins(0, p, tmp + 1, A[j].a, A[j].b, 1);
    }
    Get(0, p, Mb[j] + 1, 1);
    tmp = ((tmp) > (Ma[j]) ? (tmp) : (Ma[j]));
    s = 0;
    if (tmp > Ma[j]) getsum(0, p, Ma[j] + 1, tmp, 1);
    ans +=
        (long long)(tmp - Ma[j]) * q - s + (long long)(p - tmp) * (q - Mb[j]);
  }
  printf("%I64d\n", ans);
  return 0;
}
