#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
int f[4][MAXN];
long long ans, cur;
int main() {
  int n, p, q, r, m, minb, minc;
  scanf("%d%d%d%d", &n, &p, &q, &r);
  for (int i = 0; i < n; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    f[0][a] = max(f[0][a], b);
    f[1][a] = max(f[1][a], c);
    f[2][b] = max(f[2][b], c);
    f[3][c] = max(f[3][c], b);
  }
  m = max(p, max(q, r));
  for (int i = 0; i < 4; ++i)
    for (int j = m; j >= 0; --j) f[i][j] = max(f[i][j], f[i][j + 1]);
  minb = q + 1;
  minc = r + 1;
  for (int i = 1; i <= p; ++i) {
    while (minb - 1 > f[0][i]) {
      minb--;
      cur += min(r + 1 - minc, r - f[2][minb]);
    }
    while (minc - 1 > f[1][i]) {
      minc--;
      cur += min(q + 1 - minb, q - f[3][minc]);
    }
    ans += cur;
  }
  printf("%I64d\n", ans);
  return 0;
}
