#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010;
long long ans, sum;
int n, A, B, C, top, tx, ty;
struct node {
  int a, b, c;
} p[maxn];
int st[maxn], x[maxn], y[maxn];
inline int rd() {
  int ret = 0, f = 1;
  char gc = getchar();
  while (gc < '0' || gc > '9') {
    if (gc == '-') f = -f;
    gc = getchar();
  }
  while (gc >= '0' && gc <= '9') ret = ret * 10 + (gc ^ '0'), gc = getchar();
  return ret * f;
}
bool cmpa(const node &a, const node &b) { return a.a < b.a; }
bool cmpc(const node &a, const node &b) { return a.c > b.c; }
int main() {
  n = rd(), A = rd(), B = rd(), C = rd();
  int i, j;
  for (i = 1; i <= n; i++) p[i].a = rd(), p[i].b = rd(), p[i].c = rd();
  sort(p + 1, p + n + 1, cmpa);
  for (i = 1; i <= n; i++) {
    while (top && p[i].b > p[st[top]].b) top--;
    st[++top] = i;
  }
  sum = 1ll * A * B, st[top + 1] = 0;
  for (i = 1; i <= top; i++) {
    sum -= 1ll * (p[st[i]].a - p[st[i - 1]].a) * p[st[i]].b;
    for (j = p[st[i - 1]].a + 1; j <= p[st[i]].a; j++) y[j] = p[st[i]].b;
    for (j = p[st[i]].b; j > p[st[i + 1]].b; j--) x[j] = p[st[i]].a;
  }
  sort(p + 1, p + n + 1, cmpc);
  for (tx = ty = j = 1, i = C; i; i--) {
    for (; j <= n && p[j].c >= i; j++) {
      for (; tx <= p[j].a; tx++) sum -= B - max(y[tx], ty - 1);
      for (; ty <= p[j].b; ty++) sum -= A - max(x[ty], tx - 1);
    }
    ans += sum;
  }
  printf("%lld", ans);
  return 0;
}
