#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, t = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') t = -1;
    c = getchar();
  }
  while (isdigit(c)) s = s * 10 + c - 48, c = getchar();
  return s * t;
}
const int N = 5e5 + 5, inf = 1e9 + 7;
struct nod {
  int a, b, c;
  bool operator<(const nod& rhs) const { return c < rhs.c; }
} A[N];
struct node {
  int x, d;
  node(int a, int b) { x = a, d = b; }
  bool operator<(const node& rhs) const { return d < rhs.d; }
};
set<node> S;
set<node>::iterator it, itt, ittt;
long long ans = 0, sum = 0;
inline void In(int x, int d) {
  it = S.upper_bound(node(x, d));
  if (it != S.end() && it->x >= x) return;
  if (it != S.begin()) {
    it--;
    if (it->d == d && it->x >= x) return;
  }
  while (1) {
    it = S.upper_bound(node(x, d));
    if (it != S.begin()) {
      it--;
      if (it->x <= x) {
        itt = it, itt++;
        if (itt != S.end()) {
          sum -= (long long)(it->x - itt->x) * it->d;
          if (it != S.begin()) {
            ittt = it, ittt--;
            sum += (long long)(it->x - itt->x) * ittt->d;
          }
        } else {
          sum -= (long long)it->x * it->d;
          if (it != S.begin()) {
            ittt = it, ittt--;
            sum += (long long)it->x * ittt->d;
          }
        }
        S.erase(it);
      } else
        break;
    } else
      break;
  }
  if (S.size()) {
    it = S.upper_bound(node(x, d));
    if (it == S.end()) {
      itt = it, itt--;
      sum += (long long)(d - itt->d) * x;
    } else {
      if (it == S.begin()) {
        sum += (long long)d * (x - it->x);
      } else {
        itt = it, itt--;
        sum += (long long)(d - itt->d) * (x - it->x);
      }
    }
  } else
    sum = (long long)x * d;
  S.insert(node(x, d));
}
int main() {
  int n = read();
  long long p = read(), q = read(), r = read(), now = r;
  for (register int i = 1; i <= n; ++i)
    A[i].a = read(), A[i].b = read(), A[i].c = read();
  sort(A + 1, A + n + 1);
  for (register int i = 1; i <= n; ++i) In(A[i].a, A[i].b);
  int L, R = n;
  while (R) {
    L = R;
    while (L >= 1 && A[L].c == A[R].c) L--;
    ans += (now - A[R].c) * sum;
    for (register int i = L + 1; i <= R; ++i) In(p, A[i].b), In(A[i].a, q);
    now = A[R].c, R = L;
  }
  ans += now * sum;
  cout << p * q * r - ans << endl;
  return 0;
}
