#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int mx[N];
long long sum[N];
long long ans;
vector<pair<int, int> > v[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, p, q, r;
  cin >> n >> p >> q >> r;
  for (int i = (1); i < (n + 1); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    v[a].push_back(make_pair(b, c));
    mx[b] = max(mx[b], c);
  }
  for (int i = (q + 1) - 1; i >= (0); i--) mx[i] = max(mx[i], mx[i + 1]);
  for (int i = (1); i < (q + 1); i++) sum[i] = sum[i - 1] + mx[i];
  int mxq = 0, mxr = 0, k = q + 1;
  for (int i = (p + 1) - 1; i >= (1); i--) {
    for (auto x : v[i]) {
      mxq = max(mxq, x.first);
      mxr = max(mxr, x.second);
      while (k > mxq + 1 && mx[k - 1] < mxr) k--;
    }
    k = max(k, mxq + 1);
    ans += 1ll * (r - mxr) * (q - k + 1) + 1ll * r * (k - mxq - 1) -
           sum[k - 1] + sum[mxq];
  }
  cout << ans << "\n";
  return 0;
}
