#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e9;
const long long N = 5e5 + 5;
const long long base = 97;
long long add(long long x, long long y) { return (1ll * x + 1ll * y) % mod; }
long long del(long long x, long long y) {
  return ((1ll * x - 1ll * y) % mod + mod) % mod;
}
long long mul(long long x, long long y) { return (1ll * x * 1ll * y) % mod; }
long long n, p, q, r, prf[2][N];
struct IT {
  long long mn, sum;
} it[4 * N], lz[4 * N];
pair<long long, pair<long long, long long> > a[N];
void lzupdate(long long k, long long l, long long r) {
  if (lz[k].mn) {
    it[k].mn = max(it[k].mn, lz[k].mn);
    if (l != r) {
      lz[k << 1].mn = max(lz[k].mn, lz[k << 1].mn);
      lz[k << 1 | 1].mn = max(lz[k].mn, lz[k << 1 | 1].mn);
    }
  }
  lz[k].mn = 0;
  if (lz[k].sum) {
    it[k].sum = lz[k].sum * (r - l + 1);
    if (l != r) {
      lz[k << 1].sum = lz[k].sum;
      lz[k << 1 | 1].sum = lz[k].sum;
    }
  }
  lz[k].sum = 0;
}
void update(long long k, long long l, long long r, long long L, long long R,
            long long val) {
  lzupdate(k, l, r);
  if (r < L || R < l || L > R) return;
  if (L <= l && r <= R) {
    lz[k].mn = max(lz[k].mn, val);
    lz[k].sum = val;
    lzupdate(k, l, r);
    return;
  }
  long long md = (l + r) >> 1;
  update(k << 1, l, md, L, R, val);
  update(k << 1 | 1, md + 1, r, L, R, val);
  it[k].mn = min(it[k << 1].mn, it[k << 1 | 1].mn);
  it[k].sum = it[k << 1].sum + it[k << 1 | 1].sum;
}
long long get(long long k, long long l, long long r, long long L, long long R) {
  lzupdate(k, l, r);
  if (r < L || R < l || L > R) return 0;
  if (L <= l && r <= R) return it[k].sum;
  long long md = (l + r) >> 1;
  return get(k << 1, l, md, L, R) + get(k << 1 | 1, md + 1, r, L, R);
}
long long getpos(long long k, long long l, long long r, long long L,
                 long long R, long long val) {
  lzupdate(k, l, r);
  if (r < L || R < l || L > R) return 0;
  if (l == r) return l;
  long long md = (l + r) >> 1;
  if (it[k << 1].mn < val)
    return getpos(k << 1, l, md, L, R, val);
  else
    return getpos(k << 1 | 1, md + 1, r, L, R, val);
}
signed main() {
  scanf("%lld%lld%lld%lld", &n, &p, &q, &r);
  for (long long i = 1; i <= n; i++)
    scanf("%lld%lld%lld", &a[i].first, &a[i].second.first, &a[i].second.second);
  sort(a + 1, a + 1 + n);
  prf[0][n + 1] = 0, prf[1][n + 1] = 0;
  for (long long i = n; i >= 1; i--) {
    prf[0][i] = a[i].second.first;
    prf[1][i] = a[i].second.second;
    prf[0][i] = max(prf[0][i], prf[0][i + 1]);
    prf[1][i] = max(prf[1][i], prf[1][i + 1]);
  }
  long long sum = 0;
  for (long long i = 0; i <= n; i++) {
    long long j = i + 1, pos;
    if (get(1, 1, q, a[i].second.first, a[i].second.first) <
        a[i].second.second) {
      pos = getpos(1, 1, q, 1, a[i].second.first, a[i].second.second);
      update(1, 1, q, pos, a[i].second.first, a[i].second.second);
    }
    while (j <= n && a[i].first == a[j].first) {
      if (get(1, 1, q, a[j].second.first, a[j].second.first) <
          a[j].second.second) {
        pos = getpos(1, 1, q, 1, a[j].second.first, a[j].second.second);
        update(1, 1, q, pos, a[j].second.first, a[j].second.second);
      }
      ++j;
    }
    long long b = prf[0][j], c = prf[1][j];
    long long l, ra;
    if (j == n + 1)
      ra = p;
    else
      ra = a[j].first;
    l = a[i].first;
    long long val = ra - l;
    if (get(1, 1, q, q, q) >= c)
      sum += val * ((q - b) * r - get(1, 1, q, b + 1, q));
    else {
      pos = max(b + 1, getpos(1, 1, q, 1, q, c));
      sum += val * ((q - pos + 1) * (r - c) + (pos - 1 - b) * r -
                    get(1, 1, q, b + 1, pos - 1));
    }
    j--;
    i = j;
  }
  printf("%lld", sum);
}
