#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 5, mod = 998244353;
long long n, p, q, r;
struct abc {
  long long a, b, c;
} t[N];
long long ab[N], ac[N], bc[N], s[N], ans;
int main() {
  cin >> n >> p >> q >> r;
  for (long long i = 1; i <= n; i++)
    scanf("%lld%lld%lld", &t[i].a, &t[i].b, &t[i].c);
  for (long long i = 1; i <= n; i++) {
    bc[t[i].b] = max(bc[t[i].b], t[i].c);
    ac[t[i].a] = max(ac[t[i].a], t[i].c);
    ab[t[i].a] = max(ab[t[i].a], t[i].b);
  }
  for (long long i = q; i >= 1; i--) bc[i] = max(bc[i], bc[i + 1]);
  for (long long i = p; i >= 1; i--) ac[i] = max(ac[i], ac[i + 1]);
  for (long long i = p; i >= 1; i--) ab[i] = max(ab[i], ab[i + 1]);
  for (long long i = 1; i <= q; i++) s[i] = s[i - 1] + bc[i];
  long long t = 1;
  for (long long i = 1; i <= p; i++) {
    ans += r * (q - ab[i]);
    while (bc[t] > ac[i]) t++;
    long long tot = 0;
    long long tmp = ac[i] * (q - t + 1) + s[t - 1] - s[ab[i]];
    if (t - 1 <= ab[i]) tmp = ac[i] * (q - ab[i]);
    ans -= tmp;
  }
  cout << ans;
}
