#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e5 + 10;
long long ans;
long long n, p, q, r;
long long a[maxn];
long long b[maxn];
long long c[maxn];
long long mn[4 * maxn];
long long mx[4 * maxn];
long long seg[4 * maxn];
long long lazy[4 * maxn];
vector<pair<pair<long long, long long>, long long>> bois[maxn];
void in();
void solve();
void push(long long, long long, long long);
void upd(long long, long long, long long, long long, long long, long long);
long long get(long long, long long, long long, long long, long long);
void out();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  in();
  solve();
  out();
}
void in() {
  cin >> n >> p >> q >> r;
  for (long long i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
}
void solve() {
  for (long long i = 0; i < n; i++) {
    bois[a[i] - 1].push_back({{0, b[i]}, r});
    bois[a[i] - 1].push_back({{b[i], q}, c[i]});
    bois[p - 1].push_back({{0, b[i]}, c[i]});
  }
  ans = p * q * r;
  for (long long i = p - 1; i >= 0; i--) {
    for (auto x : bois[i])
      upd(1, 0, q, x.first.first, x.first.second, x.second);
    ans -= seg[1];
  }
}
void upd(long long id, long long l, long long r, long long L, long long R,
         long long x) {
  if (r <= L || R <= l || mn[id] >= x) return;
  if (L <= l && r <= R && mx[id] <= x) {
    seg[id] = x * (r - l);
    mn[id] = x;
    mx[id] = x;
    lazy[id] = max(lazy[id], x);
    return;
  }
  if (lazy[id]) push(id, l, r);
  long long mid = (l + r) >> 1;
  upd(id << 1, l, mid, L, R, x);
  upd(id << 1 | 1, mid, r, L, R, x);
  mn[id] = min(mn[id << 1], mn[id << 1 | 1]);
  mx[id] = max(mx[id << 1], mx[id << 1 | 1]);
  seg[id] = seg[id << 1] + seg[id << 1 | 1];
}
void push(long long id, long long l, long long r) {
  long long mid = (l + r) >> 1;
  seg[id << 1] = (mid - l) * lazy[id];
  seg[id << 1 | 1] = (r - mid) * lazy[id];
  mn[id << 1] = lazy[id];
  mn[id << 1 | 1] = lazy[id];
  mx[id << 1] = lazy[id];
  mx[id << 1 | 1] = lazy[id];
  lazy[id << 1] = lazy[id];
  lazy[id << 1 | 1] = lazy[id];
  lazy[id] = 0;
}
void out() { cout << ans; }
