#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
using ll = long long;
int n, la, lb, lc, mx[N];
struct Node {
  int b, c;
};
vector<Node> d[N];
ll ans, sum[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> la >> lb >> lc;
  for (int i = 1; i <= n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a].push_back({b, c});
    mx[b] = max(mx[b], c);
  }
  for (int i = lb; i > 0; --i) mx[i] = max(mx[i], mx[i + 1]);
  for (int i = 1; i <= lb; i++) sum[i] = sum[i - 1] + mx[i];
  int mxb = 0, mxc = 0, kk = lb + 1;
  for (int i = la; i > 0; --i) {
    for (auto &j : d[i]) {
      int y = j.b, z = j.c;
      mxb = max(mxb, y);
      mxc = max(mxc, z);
      while (kk > mxb + 1 && mx[kk - 1] < mxc) --kk;
    }
    kk = max(kk, mxb + 1);
    ans += ll(lc - mxc) * (lb - kk + 1) + ll(kk - mxb - 1) * lc - sum[kk - 1] +
           sum[mxb];
  }
  cout << ans << endl;
  return 0;
}
