#include <bits/stdc++.h>
using namespace std;
unsigned int d0, d1, d2, szv, m, szl, szr, top;
struct pt {
  unsigned int a[3];
  unsigned int operator[](unsigned int i) const { return a[i]; };
  unsigned int& operator[](unsigned int i) { return a[i]; };
  pt(unsigned int x, unsigned int y, unsigned int z) {
    a[0] = x;
    a[1] = y;
    a[2] = z;
  }
  pt(const pt& p) {
    for (unsigned int(i) = (0); (i) < (3); (i)++) a[i] = p.a[i];
  }
  pt() {}
};
int cmp(pt p1, pt p2) {
  for (unsigned int(i) = (0); (i) < (3); (i)++) {
    if (p1[i] < p2[i]) return 1;
    if (p1[i] > p2[i]) return 0;
  }
  return 0;
}
int operator!=(pt p1, pt p2) {
  for (unsigned int(i) = (0); (i) < (3); (i)++)
    if (p1[i] != p2[i]) return 1;
  return 0;
}
pt p, lo;
long long area(const pt& p) {
  long long ans = 1;
  for (unsigned int(i) = (0); (i) < (3); (i)++) ans *= p[i];
  return ans;
}
pt inter(const pt& p1, const pt& p2) {
  pt p;
  for (unsigned int(i) = (0); (i) < (3); (i)++) p[i] = min(p1[i], p2[i]);
  return p;
}
unsigned int ok(const pt& p, const pt& lo) {
  for (unsigned int(i) = (0); (i) < (3); (i)++)
    if (p[i] <= lo[i]) return 0;
  return 1;
}
long long go(vector<pt>& v, pt hi, unsigned int d) {
  if (hi[d] == 0) return 0;
  szv = ((int)v.size());
  lo = pt(0, 0, 0);
  top = 0;
  d0 = (d + 2) % 3;
  d1 = (d + 1) % 3;
  for (unsigned int(i) = (0); (i) < (szv); (i)++) {
    p = v[i];
    top = max(top, p[d]);
  }
  for (unsigned int(i) = (0); (i) < (szv); (i)++) {
    p = v[i];
    for (unsigned int(d0) = (0); (d0) < (3); (d0)++)
      for (unsigned int(d1) = (d0 + 1); (d1) < (3); (d1)++) {
        d2 = 3 - d1 - d0;
        if (p[d0] == hi[d0] && p[d1] == hi[d1]) lo[d2] = max(lo[d2], p[d2]);
      }
  }
  long long ans =
      (long long)(hi[d] - top) * (long long)hi[d0] * (long long)hi[d1];
  hi[d] = top;
  m = 0;
  for (unsigned int(i) = (0); (i) < (szv); (i)++) {
    v[m] = v[i];
    m += ok(v[i], lo);
  }
  szv = m;
  for (unsigned int(j) = (0); (j) < (3); (j)++) hi[j] -= lo[j];
  for (unsigned int(i) = (0); (i) < (szv); (i)++) {
    for (unsigned int(j) = (0); (j) < (3); (j)++) v[i][j] -= lo[j];
  }
  if (szv <= 2) {
    if (szv == 0) return ans + area(hi);
    if (szv == 1) return ans + area(hi) - area(v[0]);
    if (szv == 2)
      return ans + area(hi) - area(v[0]) - area(v[1]) + area(inter(v[0], v[1]));
  }
  long long bm = 0;
  for (unsigned int(i) = (0); (i) < (szv); (i)++) bm += v[i][d];
  m = bm / szv;
  szl = szv;
  szr = 0;
  for (unsigned int(i) = (0); (i) < (szv); (i)++) szr += (v[i][d] > m);
  vector<pt> l(szl);
  vector<pt> r(szr);
  szr = 0;
  pt lhi = hi;
  lhi[d] = m;
  pt rhi = hi;
  rhi[d] = hi[d] - m;
  for (unsigned int(i) = (0); (i) < (szv); (i)++) {
    p = v[i];
    if (p[d] <= m)
      l[i] = p;
    else {
      p[d] -= m;
      r[szr++] = p;
      p[d] = m;
      l[i] = p;
    }
  }
  unsigned int nd = (d + 1) % 3;
  v = vector<pt>();
  return ans + go(l, lhi, nd) + go(r, rhi, nd);
}
int main() {
  unsigned int n, p, q, r;
  scanf("%u %u %u %u\n", &n, &p, &q, &r);
  vector<pt> v(3 * n);
  for (unsigned int(i) = (0); (i) < (n); (i)++) {
    unsigned int x, y, z;
    scanf("%u %u %u\n", &x, &y, &z);
    v[3 * i] = pt(p, y, z);
    v[3 * i + 1] = pt(x, q, z);
    v[3 * i + 2] = pt(x, y, r);
  }
  sort((v).begin(), (v).end(), cmp);
  vector<pt> u;
  u.reserve(3 * n);
  u.push_back(v[0]);
  for (unsigned int(i) = (1); (i) < (3 * n); (i)++)
    if (v[i] != u.back()) u.push_back(v[i]);
  printf("%lld\n", go(u, pt(p, q, r), 0));
  return 0;
}
