#include <bits/stdc++.h>
using namespace std;
long long ans, now, all;
struct node {
  int x, y;
  friend bool operator<(node a, node b) {
    if (a.x != b.x) return a.x < b.x;
    return a.y < b.y;
  }
};
vector<node> f[510000];
int n, p, q, r;
set<node> s;
set<node>::iterator it;
set<node>::iterator its;
vector<node> clr;
int main() {
  scanf("%d %d %d %d", &n, &p, &q, &r);
  for (int i = 1; i <= n; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    f[r].push_back({x, y});
    f[z].push_back({x, q});
    f[z].push_back({p, y});
  }
  s.insert({0, q});
  s.insert({p + 1, 0});
  all = (long long)p * (long long)q;
  for (int i = r; i >= 1; i--) {
    for (int j = 0; j < f[i].size(); j++) {
      node p = f[i][j];
      it = s.lower_bound(p);
      node pp = *it;
      if (pp.y >= p.y) continue;
      it = s.lower_bound(p);
      its = it;
      it--;
      clr.clear();
      int nn = p.x;
      while ((*its).y < p.y) {
        now += (long long)(nn - (*it).x) * (long long)(p.y - (*its).y);
        if ((*it).y >= p.y) break;
        clr.push_back(*it);
        its = it;
        nn = (*its).x;
        it--;
      }
      for (int k = 0; k < clr.size(); k++) s.erase(clr[k]);
      s.insert(p);
    }
    ans += all - now;
  }
  cout << ans << endl;
  return 0;
}
