#include <bits/stdc++.h>
int n, p, q, r;
long long seg[((1 << 19) << 1) + 10];
int lazy[((1 << 19) << 1) + 10], min[((1 << 19) << 1) + 10],
    sufb[(1 << 19) + 10], sufc[(1 << 19) + 10];
std::pair<std::pair<int, int>, int> card[(1 << 19) + 10];
void pushdown(int u, int l, int r) {
  if (!lazy[u]) return;
  int m = l + r >> 1, ls = u << 1, rs = ls | 1;
  min[ls] = min[rs] = lazy[ls] = lazy[rs] = lazy[u];
  seg[ls] = 1ll * (m - l + 1) * lazy[u];
  seg[rs] = 1ll * (r - m) * lazy[u];
  lazy[u] = 0;
}
void pushup(int u) {
  int ls = u << 1, rs = ls | 1;
  seg[u] = seg[ls] + seg[rs];
  min[u] = std::min(min[ls], min[rs]);
}
void insert(int u, int l, int r, int ql, int qr, int val) {
  if (ql > qr) return;
  if (ql <= l && r <= qr) {
    seg[u] = 1ll * (r - l + 1) * val;
    lazy[u] = min[u] = val;
    return;
  }
  pushdown(u, l, r);
  int m = l + r >> 1, ls = u << 1, rs = ls | 1;
  if (!(m < ql)) insert(ls, l, m, ql, qr, val);
  if (!(qr < m + 1)) insert(rs, m + 1, r, ql, qr, val);
  pushup(u);
}
long long getsum(int u, int l, int r, int ql, int qr) {
  if (ql > qr) return 0;
  if (ql <= l && r <= qr) return seg[u];
  pushdown(u, l, r);
  int m = l + r >> 1, ls = u << 1, rs = ls | 1;
  long long ret = 0;
  if (!(m < ql)) ret += getsum(ls, l, m, ql, qr);
  if (!(qr < m + 1)) ret += getsum(rs, m + 1, r, ql, qr);
  return ret;
}
int getmin(int u, int l, int r, int val) {
  if (l == r) return l;
  pushdown(u, l, r);
  int m = l + r >> 1, ls = u << 1, rs = ls | 1;
  if (min[ls] < val) return getmin(ls, l, m, val);
  return getmin(rs, m + 1, r, val);
}
int main() {
  scanf("%d%d%d%d", &n, &p, &q, &r);
  for (int i = 1; i <= n; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    card[i] = {{a, b}, c};
  }
  std::sort(card + 1, n + card + 1);
  for (int i = n; i; --i) {
    sufb[i] = std::max(sufb[i + 1], card[i].first.second);
    sufc[i] = std::max(sufc[i + 1], card[i].second);
  }
  long long ans = 0;
  for (int a = 1, i = 1; a <= p; ++a) {
    for (; i <= n && card[i].first.first < a; ++i) {
      int sit = getmin(1, 1, (1 << 19), card[i].second);
      insert(1, 1, (1 << 19), sit, card[i].first.second, card[i].second);
    }
    ans += 1ll * (q - sufb[i]) * r;
    int sit = std::max(sufb[i] + 1, getmin(1, 1, (1 << 19), sufc[i]));
    ans -= getsum(1, 1, (1 << 19), sufb[i] + 1, sit - 1);
    ans -= 1ll * (q - sit + 1) * sufc[i];
  }
  printf("%I64d\n", ans);
  return 0;
}
