#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 500010;
struct node {
  long long a, b, c;
} a[N];
long long n, A, B, C, ans, Sum, Max, L, x[N];
inline bool cmp(node a, node b) { return a.a > b.a; }
long long sum[N];
inline void Add(int x, long long y) {
  for (; x; x -= x & -x) sum[x] = max(sum[x], y);
}
inline int Query(int x) {
  long long ans = 0;
  for (; x <= B; x += x & -x) ans = max(ans, sum[x]);
  return ans;
}
long long c[N], s[N];
inline void add(int x, long long y) {
  for (; x <= C + 1; x += x & -x) c[x] += y;
}
inline long long query(int x) {
  long long ans = 0;
  for (; x; x -= x & -x) ans += c[x];
  return ans;
}
inline void ADD(int x, long long y) {
  for (; x <= C + 1; x += x & -x) s[x] += y;
}
inline long long query2(int x) {
  long long ans = 0;
  for (; x; x -= x & -x) ans += s[x];
  return ans;
}
int main() {
  n = read(), A = read(), B = read(), C = read();
  for (register int i = (1); i <= (n); i++)
    a[i] = (node){read(), read(), read()};
  sort(a + 1, a + 1 + n, cmp);
  for (register int i = (1); i <= (n); i++) Add(a[i].b, a[i].c);
  int l = 1, r;
  ans = A * B * C;
  for (register int i = (1); i <= (B); i++) {
    x[i] = Query(i);
    add(x[i] + 1, 1), ADD(x[i] + 1, x[i]), Sum += x[i];
  }
  ans -= (A - a[1].a) * Sum, L = 0;
  while (l <= n) {
    r = l;
    while (a[l].a == a[r + 1].a && r < n) r++;
    for (register int i = (l); i <= (r); i++)
      if (a[i].b > L) {
        for (register int j = (L + 1); j <= (a[i].b); j++)
          add(x[j] + 1, -1), ADD(x[j] + 1, -x[j]);
        L = a[i].b;
      }
    for (register int i = (l); i <= (r); i++) Max = max(Max, a[i].c);
    Sum = L * C;
    Sum += query(Max + 1) * Max;
    if (Max + 1 <= C) Sum += query2(C + 1) - query2(Max + 1);
    l = r + 1, ans -= (a[l - 1].a - a[l].a) * Sum;
  }
  printf("%lld", ans);
}
