#include <bits/stdc++.h>
using namespace std;
long long ans, sum;
int n, A, B, C, top, tx, ty;
int st[500020], x[500020], y[500020];
struct node {
  int a, b, c;
} p[500020];
bool cmpa(node a, node b) { return a.a < b.a; }
bool cmpc(node a, node b) { return a.c > b.c; }
int main() {
  int i, j;
  scanf("%d%d%d%d", &n, &A, &B, &C);
  for (i = 1; i <= n; ++i) scanf("%d%d%d", &p[i].a, &p[i].b, &p[i].c);
  sort(p + 1, p + 1 + n, cmpa);
  for (i = 1; i <= n; ++i) {
    while (top && p[i].b > p[st[top]].b) --top;
    st[++top] = i;
  }
  sum = (long long)A * B, st[top + 1] = 0;
  for (i = 1; i <= top; ++i) {
    sum -= (long long)(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 + 1 + n, 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\n", ans);
  return 0;
}
