#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
long long sum[N];
int mxx[N], mxy[N], mx[N];
struct node {
  int x, y, z;
} a[N];
bool cmp(node a, node b) { return a.z < b.z; }
int main() {
  int n, p, q, r;
  scanf("%d%d%d%d", &n, &p, &q, &r);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
  }
  sort(a + 1, a + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    mx[a[i].x] = max(mx[a[i].x], a[i].y);
  }
  for (int i = n; i >= 1; i--) {
    mxx[i] = max(mxx[i + 1], a[i].x);
    mxy[i] = max(mxy[i + 1], a[i].y);
  }
  for (int i = p; i >= 1; i--) {
    mx[i] = max(mx[i], mx[i + 1]);
  }
  for (int i = 1; i <= p; i++) {
    sum[i] = sum[i - 1] + q - mx[i];
  }
  long long ans = 0;
  for (int i = 1, j = 1; i <= r; i++) {
    while (j <= n && a[j].z < i) j++;
    int l = mxx[j] + 1, r = p + 1;
    while (l < r) {
      int mid = (l + r) / 2;
      if (mx[mid] >= mxy[j] + 1) {
        l = mid + 1;
      } else {
        r = mid;
      }
    }
    ans += 1ll * (p - l + 1) * (q - mxy[j]) + sum[l - 1] - sum[mxx[j]];
  }
  printf("%I64d\n", ans);
  return 0;
}
