#include<iostream>
#include<cmath>
using namespace std;
int main() {
int w, x, h,q;
cin >> w >> x >> h >> q;
int x1, y1, z1, x2, y2, z2;
cin >> x1 >> y1 >> z1>> x2 >> y2 >> z2;
int a[3] = { x1, y1, z1 }, b[3] = { x2, y2, z2 };
while (--q) {
cin >> x1 >> y1 >> z1>> x2 >> y2 >> z2;
a[0] = min(a[0], x1);a[1] = min(a[1], y1);a[2] = min(a[2], z1);
b[0] = max(b[0], x2);b[1] = max(b[1], y2);b[2] = max(b[2], z2);
}
int sum = (b[0] - a[0] + 1) * (b[1] - a[1] + 1) * (b[2] - a[2] + 1);
cout << w * x * h - sum;
return 0;
}
//样例可过