Example

Input

2 2 2 1
0 0 0


Output

24
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int dx[] = {1,0,0,-1,0,0};
int dy[] = {0,1,0,0,-1,0};
int dz[] = {0,0,1,0,0,-1};
ll A,B,C,N;
ll x[1000+10],y[1000+10],z[1000+10];

bool space(int vx,int vy, int vz,int cur){

    for(int i=0; i<cur; i++){
        if(vx == x[i] && vy == y[i] && vz == z[i]) return true;
    }

    if(vx < 0 || vy < 0 || vz < 0 || vx >= A || vy >= B || vz >= C) return true;

    return false;
}

int main(){
    cin>>A>>B>>C>>N;
    int cnt = 0;
    ll sum = 0;
    for(int i=0; i<N; i++){
        cin>>x[i]>>y[i]>>z[i];
        cnt = 0;

        for(int j=0; j<6; j++){
            int vx = x[i]+dx[j];
            int vy = y[i]+dy[j];
            int vz = z[i]+dz[j];
            if(space(vx,vy,vz,i)) cnt++;
        }

        sum += (6-cnt*2);
    }

    sum += 2*(A*B+B*C+C*A);

    cout<<sum<<endl;

    return 0;
}
