Example

Input

2 2 2 1
0 0 0


Output

24
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;

struct pos {
    ll p[3];
    bool operator<(pos const& oth) const {
        pair<ll, pair<ll, ll>> p1, p2;
        p1.first = p[0], p1.second.first = p[1], p1.second.second = p[2];
        p2.first = oth.p[0], p2.second.first = oth.p[1], p2.second.second = oth.p[2];
        return p1 < p2;
    }
    void print() const {
        cout << p[0] << " " << p[1] << " " << p[2] << endl;
    }
};

int main() {
    ll A[3], N;
    cin >> A[0] >> A[1] >> A[2] >> N;
    ll res = (A[0]*A[1] + A[1]*A[2] + A[2]*A[0]) * 2;
    map<pos, int> m[3];
    for(int i=0; i<N; ++i) {
        pos p;
        for(int j=0; j<3; ++j) {
            cin >> p.p[j];
        }
        for(int j=0; j<3; ++j) {
            for(int k=0; k<2; ++k) {
                pos p2 = p;
                p2.p[j] += k;
                m[j][p2]++; 
            }
        }
    }
    for(int i=0; i<3; ++i) {
        for(auto& pa : m[i]) {
            if(pa.first.p[i] == 0 || pa.first.p[i] == A[i] || pa.second == 2) {
                res--;
                auto p2 = pa.first;
                if(m[i].count(p2) && m[i][p2] == 2) {
                    res++;
                }
            } else {
                res++;
            }
        }
    }
    cout << res << endl;
}
