#include <bits/stdc++.h>
using namespace std;
int n, p, q, r;
int A[500050], B[500050], C[500050];
vector<tuple<int, int, int> > E;
void solve() {
  scanf("%d%d%d%d", &n, &p, &q, &r);
  for (int i = 1; i <= n; i++)
    scanf("%d%d%d", A + i, B + i, C + i), C[i] = r - C[i];
  for (int i = 1; i <= n; i++) {
    E.emplace_back(1, A[i], B[i]);
    E.emplace_back(C[i] + 1, p, B[i]);
    E.emplace_back(C[i] + 1, A[i], q);
  }
  sort((E).begin(), (E).end());
  map<int, int> M;
  long long now = 0, ans = 0;
  M[0] = q + 1;
  M[p + 1] = 0;
  for (int i = 0; i < ((int)(E).size()); i++) {
    int x = get<1>(E[i]), y = get<2>(E[i]);
    auto it = M.lower_bound(x);
    if (it->second < y) {
      while (it->second <= y) {
        int u = min(x, it->first);
        auto jt = it;
        --jt;
        int l = jt->first;
        now += (u - l) * (long long)(y - it->second);
        if (it->first <= x) M.erase(it);
        it = jt;
      }
      M[x] = y;
    }
    ans += now *
           (long long)((i == ((int)(E).size()) - 1 ? r + 1 : get<0>(E[i + 1])) -
                       get<0>(E[i]));
  }
  printf("%lld\n", (long long)p * q * r - ans);
}
int main() {
  int Tc = 1;
  for (int tc = 1; tc <= Tc; tc++) {
    solve();
  }
  return 0;
};
