Example

Input

2 2 2 1
0 0 0


Output

24
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

lint a, b, c;
int n;
map<pair<pii, int>, int> S;
set<pair<pii, int>> T;

int dx[6] = {1, -1, 0, 0, 0, 0};
int dy[6] = {0, 0, 1, -1, 0, 0};
int dz[6] = {0, 0, 0, 0, 1, -1};

bool in(int x, int y, int z){
    return 0<=x && x<a && 0<=y && y<b && 0<=z && z<c;
}

int surface(int x, int y, int z){
    int ret = 0;
    rep(i, 6){
        int nx = x+dx[i], ny = y+dy[i], nz = z+dz[i];
        ret += !in(nx, ny, nz);
    }
    return ret;
}

int main(){
    scanf("%lld%lld%lld%d", &a, &b, &c, &n);
    lint ans = (a*b + b*c + c*a) * 2;
    rep(_, n){
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        if(S.find({{x, y}, z}) != S.end()) ans -= S[{{x, y}, z}];
        else ans -= surface(x, y, z);
        T.insert({{x, y}, z});

        rep(i, 6){
            int nx = x+dx[i], ny = y+dy[i], nz = z+dz[i];
            if(in(nx, ny, nz) && T.find({{nx, ny}, nz}) == T.end()){
                if(S.find({{nx, ny}, nz}) != S.end()) ++S[{{nx, ny}, nz}];
                else S[{{nx, ny}, nz}] = surface(nx, ny, nz) + 1;
                ++ans;
            }
        }
    }
    printf("%lld\n", ans);
}
