#include <bits/stdc++.h>
using namespace std;
int n, P, Q, R;
vector<int> pq, pr, qp, qr, rp, rq;
inline long long od(vector<int> &v, int z) {
  long long an = 0;
  for (int i = 1; i < (int)(v.size()); ++i) an += v[i];
  return an * z;
}
inline long long td(vector<int> &a, vector<int> &b) {
  long long an = 0;
  vector<long long> s(a.size(), 0);
  for (int i = a.size() - 2; i > 0; --i) s[i] = a[i] + s[i + 1];
  int j = 1;
  for (int i = 1; i < (int)(b.size()); ++i) {
    while (j + 1 < (int)a.size() && a[j] > b[i]) ++j;
    an += (long long)(j - 1) * b[i] + s[j];
  }
  return an;
}
inline long long thd(vector<int> &a, vector<int> &b, vector<int> &c) {
  long long an = 0;
  vector<long long> s(a.size(), 0);
  for (int i = a.size() - 2; i > 0; --i) s[i] = a[i] + s[i + 1];
  int j = 1;
  for (int i = 1; i < (int)(b.size()); ++i) {
    while (j + 1 < (int)a.size() && a[j] > b[i]) ++j;
    if (c[i] >= j)
      an += (long long)(j - 1) * b[i] + s[j] - s[c[i] + 1];
    else
      an += (long long)c[i] * b[i];
  }
  return an;
}
int main() {
  scanf("%d%d%d%d", &n, &P, &Q, &R);
  pq.resize(P + 2);
  pr.resize(P + 2);
  qp.resize(Q + 2);
  qr.resize(Q + 2);
  rp.resize(R + 2);
  rq.resize(R + 2);
  for (int i = 0; i < (int)(n); ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    pq[a] = max(pq[a], b);
    pr[a] = max(pr[a], c);
    qp[b] = max(qp[b], a);
    qr[b] = max(qr[b], c);
    rp[c] = max(rp[c], a);
    rq[c] = max(rq[c], b);
  }
  for (int i = P - 1; i > 0; --i) pq[i] = max(pq[i], pq[i + 1]);
  for (int i = P - 1; i > 0; --i) pr[i] = max(pr[i], pr[i + 1]);
  for (int i = Q - 1; i > 0; --i) qp[i] = max(qp[i], qp[i + 1]);
  for (int i = Q - 1; i > 0; --i) qr[i] = max(qr[i], qr[i + 1]);
  for (int i = R - 1; i > 0; --i) rp[i] = max(rp[i], rp[i + 1]);
  for (int i = R - 1; i > 0; --i) rq[i] = max(rq[i], rq[i + 1]);
  long long an = (long long)P * Q * R;
  an -= od(pq, R) + od(rq, P) + od(pr, Q);
  an += td(pq, rq) + td(qp, rp) + td(pr, qr);
  an -= thd(pr, qr, qp);
  printf("%lld\n", an);
}
