#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1e9 + 100;
const long long LINF = 1e18 + 100;
struct Card {
  int x, y, z;
};
struct node {
  long long val;
  long long mn, mx;
};
int n, p, q, r;
Card a[500100];
int ymx[500100], zmx[500100];
long long ans;
node seg[4 * 500100];
long long lz[4 * 500100];
void pushdown(int v, int l, int r) {
  if (!lz[v]) return;
  int mid = (r + l) / 2;
  for (int i = (0); i < (2); i++)
    seg[2 * v + i].mn = seg[2 * v + i].mx = lz[2 * v + i] = lz[v];
  seg[2 * v].val = (mid - l + 1) * lz[v];
  seg[2 * v + 1].val = (r - mid) * lz[v];
  lz[v] = 0;
}
void maximize(int R, int x, int v = 1, int l = 0, int r = 500100) {
  if (l > R || seg[v].mn >= x) return;
  if (r <= R && seg[v].mx <= x) {
    seg[v].mn = seg[v].mx = lz[v] = x;
    seg[v].val = (r - l + 1) * (long long)x;
    return;
  }
  int mid = (r + l) / 2;
  pushdown(v, l, r);
  maximize(R, x, 2 * v, l, mid);
  maximize(R, x, 2 * v + 1, mid + 1, r);
  seg[v].mn = min(seg[2 * v].mn, seg[2 * v + 1].mn);
  seg[v].mx = max(seg[2 * v].mx, seg[2 * v + 1].mx);
  seg[v].val = seg[2 * v].val + seg[2 * v + 1].val;
}
long long get(int L, int x, int v = 1, int l = 0, int r = 500100) {
  if (r < L || seg[v].mx <= x) return 0;
  if (l >= L && seg[v].mn > x) return seg[v].val - (r - l + 1) * (long long)x;
  int mid = (r + l) / 2;
  pushdown(v, l, r);
  return get(L, x, 2 * v, l, mid) + get(L, x, 2 * v + 1, mid + 1, r);
}
int32_t main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> p >> q >> r;
  for (int i = (1); i < (n + 1); i++) cin >> a[i].x >> a[i].y >> a[i].z;
  a[0] = {0, 0, 0};
  a[n + 1] = {p, 0, 0};
  sort(a + 1, a + n + 1,
       [&](const Card &a, const Card &b) { return a.x < b.x; });
  for (int i = n; i >= 1; i--) {
    ymx[i] = max(ymx[i + 1], a[i].y);
    zmx[i] = max(zmx[i + 1], a[i].z);
  }
  for (int i = (1); i < (n + 2); i++) {
    long long dif = a[i].x - a[i - 1].x;
    long long bad = get(ymx[i] + 1, zmx[i]);
    long long area = (q - ymx[i]) * (long long)(r - zmx[i]);
    ans += dif * (area - bad);
    maximize(a[i].y, a[i].z);
  }
  cout << ans << '\n';
  return 0;
}
