#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using db = double;
const int mxn = 500006;
int n;
ll X, Y, Z;
vector<pair<int, int>> ins[mxn];
ll ans = 0;
ll sum = 0;
map<ll, ll> s;
void rem(ll x, ll y) {
  s.erase(x);
  sum -= (x - prev(s.upper_bound(x))->first) * (y - s.upper_bound(x)->second);
}
void add(ll x, ll y) {
  auto t = s.lower_bound(x);
  if (t->second >= y) return;
  while (prev(s.upper_bound(x))->second <= y)
    rem(prev(s.upper_bound(x))->first, prev(s.upper_bound(x))->second);
  sum += (x - prev(s.upper_bound(x))->first) * (y - s.upper_bound(x)->second);
  s[x] = y;
}
int main() {
  cin >> n >> X >> Y >> Z;
  for (int i = 1; i <= n; ++i) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    ins[Z].push_back({x, y});
    ins[z].push_back({x, Y});
    ins[z].push_back({X, y});
  }
  s[0] = Y + 1;
  s[X + 1] = 0;
  for (int i = Z; i >= 1; --i) {
    for (auto j : ins[i]) add(j.first, j.second);
    ans += sum;
  }
  cout << X * Y * Z - ans << endl;
  return 0;
}
