#include <bits/stdc++.h>
using namespace std;
int n, P, Q, R;
int mx[2000010], mn[2000010];
int lazy[2000010];
long long sum[2000010];
void update(int root) {
  sum[root] = sum[root << 1] + sum[root << 1 | 1];
  mx[root] = max(mx[root << 1], mx[root << 1 | 1]);
  mn[root] = min(mn[root << 1], mn[root << 1 | 1]);
  return;
}
void change(int root, int l, int r, int to) {
  mx[root] = to;
  mn[root] = to;
  sum[root] = 1ll * (r - l + 1) * to;
  lazy[root] = to;
  return;
}
void pushdown(int root, int l, int r) {
  if (!lazy[root]) return;
  int mid = (l + r) >> 1;
  change(root << 1, l, mid, lazy[root]);
  change(root << 1 | 1, mid + 1, r, lazy[root]);
  lazy[root] = 0;
  return;
}
void Add(int root, int l, int r, int x, int y) {
  if (mn[root] >= y) return;
  if (r <= x) {
    if (mx[root] <= y) {
      change(root, l, r, y);
      return;
    }
    int mid = (l + r) >> 1;
    pushdown(root, l, r);
    Add(root << 1, l, mid, x, y);
    Add(root << 1 | 1, mid + 1, r, x, y);
    update(root);
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(root, l, r);
  Add(root << 1, l, mid, x, y);
  if (x > mid) Add(root << 1 | 1, mid + 1, r, x, y);
  update(root);
  return;
}
long long Query(int root, int l, int r, int x, int y) {
  if (r <= x) return 0;
  if (l > x) {
    if (mx[root] <= y) return 1ll * (r - l + 1) * (R - y);
    if (mn[root] >= y) return 1ll * (r - l + 1) * R - sum[root];
  }
  pushdown(root, l, r);
  int mid = (l + r) >> 1;
  long long ans =
      Query(root << 1, l, mid, x, y) + Query(root << 1 | 1, mid + 1, r, x, y);
  return ans;
}
struct Val {
  int a, b, c;
} v[500010];
bool cmp(Val a, Val b) { return a.a < b.a; }
int mxQ[500010], mxR[500010];
int main() {
  scanf("%d %d %d %d", &n, &P, &Q, &R);
  mxQ[n + 1] = mxR[n + 1] = 0;
  for (int i = 1; i <= n; i++) scanf("%d %d %d", &v[i].a, &v[i].b, &v[i].c);
  sort(v + 1, v + n + 1, cmp);
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    mxQ[i] = max(mxQ[i + 1], v[i].b);
    mxR[i] = max(mxR[i + 1], v[i].c);
  }
  int now = 1;
  for (int i = 1; i <= P; i++) {
    while (now <= n && v[now].a < i) {
      Add(1, 1, Q, v[now].b, v[now].c);
      now++;
    }
    ans += Query(1, 1, Q, mxQ[now], mxR[now]);
  }
  printf("%I64d\n", ans);
  return 0;
}
