#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 500010, LOG = 20;
long long n, m, k, p, q, r, ans;
long long A[MAXN], B[MAXN], C[MAXN];
long long maxb[MAXN], maxc[MAXN];
long long seg[MAXN << 2], lazy[MAXN << 2], Mn[MAXN << 2];
vector<int> vec[MAXN];
void add_lazy(int id, int len, long long lz) {
  seg[id] = len * lz;
  lazy[id] = Mn[id] = lz;
}
void shift(int id, int tl, int tr) {
  if (!lazy[id]) return;
  int mid = (tl + tr) >> 1;
  add_lazy(id << 1, mid - tl, lazy[id]);
  add_lazy(id << 1 | 1, tr - mid, lazy[id]);
  lazy[id] = 0;
}
void update(int id, int tl, int tr, int l, int r, int val) {
  if (tr <= l || r <= tl) return;
  if (l <= tl && tr <= r) {
    add_lazy(id, tr - tl, val);
    return;
  }
  shift(id, tl, tr);
  int mid = (tl + tr) >> 1;
  update(id << 1, tl, mid, l, r, val);
  update(id << 1 | 1, mid, tr, l, r, val);
  seg[id] = seg[id << 1] + seg[id << 1 | 1];
  Mn[id] = min(Mn[id << 1], Mn[id << 1 | 1]);
}
int BS(int id, int tl, int tr, int val) {
  if (tr - tl == 1) return tl;
  shift(id, tl, tr);
  int mid = (tl + tr) >> 1;
  if (Mn[id << 1] >= val) return BS(id << 1 | 1, mid, tr, val);
  return BS(id << 1, tl, mid, val);
}
long long get(int id, int tl, int tr, int l, int r) {
  if (r <= tl || tr <= l) return 0;
  if (l <= tl && tr <= r) return seg[id];
  shift(id, tl, tr);
  int mid = (tl + tr) >> 1;
  return get(id << 1, tl, mid, l, r) + get(id << 1 | 1, mid, tr, l, r);
}
void Add(int x, int y) {
  int tmp = BS(1, 1, MAXN, y);
  update(1, 1, MAXN, tmp, x + 1, y);
}
long long Get(int x, int y) {
  x++;
  y++;
  int tmp = max(BS(1, 1, MAXN, y), x);
  return get(1, 1, MAXN, x, tmp) - 1ll * (tmp - x) * (y - 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> p >> q >> r;
  for (int i = 1; i <= n; i++)
    cin >> A[i] >> B[i] >> C[i], vec[A[i]].push_back(i);
  for (int a = p; a; a--) {
    maxb[a] = maxb[a + 1];
    maxc[a] = maxc[a + 1];
    for (int id : vec[a]) {
      maxb[a] = max(maxb[a], B[id]);
      maxc[a] = max(maxc[a], C[id]);
    }
  }
  for (int a = 1; a <= p; a++) {
    ans += (q - maxb[a]) * (r - maxc[a]) - Get(maxb[a], maxc[a]);
    for (int id : vec[a]) Add(B[id], C[id]);
  }
  cout << ans << '\n';
  return 0;
}
