#include <bits/stdc++.h>
using namespace std;
long long ITmin[500000 * 4 + 1], ITmax[500000 * 4 + 1], IT[500000 * 4 + 1],
    LZ[500000 * 4 + 1], vt[500000 * 4 + 1], sl, res, sum, m,
    a[500000 * 4 + 1 + 1], b[500000 * 4 + 1 + 1], c[500000 * 4 + 1 + 1], p, q,
    r, n;
vector<int> ss[500000 * 4 + 1];
void lazy(int i, int l, int r) {
  int m = (l + r) >> 1;
  LZ[i * 2] = ITmin[i * 2] = ITmax[i * 2] = LZ[i];
  LZ[i * 2 + 1] = ITmin[i * 2 + 1] = ITmax[i * 2 + 1] = LZ[i];
  IT[i * 2] = LZ[i] * (m - l + 1);
  IT[i * 2 + 1] = LZ[i] * (r - m);
  LZ[i] = 0;
}
void cn(int l, int r, int x, int y, long long C, int i) {
  if (l > y || r < x) return;
  if (x <= l && r <= y) {
    if (ITmin[i] >= C) {
      res = r;
      return;
    }
    if (ITmax[i] < C) {
      sum += IT[i];
      IT[i] = C * (r - l + 1);
      ITmin[i] = C;
      ITmax[i] = C;
      LZ[i] = C;
      return;
    }
    int m = (l + r) >> 1;
    if (LZ[i] != 0) lazy(i, l, r);
    cn(l, m, x, y, C, i * 2);
    cn(m + 1, r, x, y, C, i * 2 + 1);
    IT[i] = IT[i * 2] + IT[i * 2 + 1];
    ITmax[i] = max(ITmax[i * 2], ITmax[i * 2 + 1]);
    ITmin[i] = min(ITmin[i * 2], ITmin[i * 2 + 1]);
  } else {
    if (LZ[i] != 0) lazy(i, l, r);
    cn(l, (l + r) >> 1, x, y, C, i * 2);
    cn(((l + r) >> 1) + 1, r, x, y, C, i * 2 + 1);
    IT[i] = IT[i * 2] + IT[i * 2 + 1];
    ITmax[i] = max(ITmax[i * 2], ITmax[i * 2 + 1]);
    ITmin[i] = min(ITmin[i * 2], ITmin[i * 2 + 1]);
  }
}
long long update(int B, int C) {
  res = 0;
  sum = 0;
  cn(1, 500000, 1, B, C, 1);
  return (long long)(B - res) * C - sum;
}
void creat(int A, int B, int C) {
  m++;
  a[m] = A;
  b[m] = B;
  c[m] = r;
  m++;
  a[m] = p;
  b[m] = B;
  c[m] = C;
  m++;
  a[m] = A;
  b[m] = q;
  c[m] = C;
}
void mysort() {
  int s = 0;
  for (int i = 1; i <= m; i++) ss[a[i]].push_back(i);
  for (int i = 500000 * 4 + 1 - 1; i > 0; i--) {
    for (int j = 0; j < ss[i].size(); j++) {
      s++;
      vt[s] = ss[i][j];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> p >> q >> r;
  int A, B, C;
  for (int i = 1; i <= n; i++) {
    cin >> A >> B >> C;
    creat(A, B, C);
  }
  mysort();
  for (int i = 1; i <= m; i++) {
    sl += a[vt[i]] * update(b[vt[i]], c[vt[i]]);
  }
  cout << p * q * r - sl;
  return 0;
}
