Example

Input

2 2 2 1
0 0 0


Output

24
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef pair<int,int>P;

struct cor
{
    int x,y,z;
    bool operator<(const cor& c) const {
        if(x != c.x){
            return x < c.x;
        }else if(y != c.y){
            return y < c.y;
        }else{
            return z < c.z;
        }
    }
};

const int MAX_N = 100005;

ll a,b,c,n;
map<cor,int> mp;

int solve(int u,int v,int w)
{
    int pl = 0;
    if(u == 0 || mp[(cor){u-1,v,w}]){
        pl--;
    }else{
        pl++;
    }
    if(u == a-1 || mp[(cor){u+1,v,w}]){
        pl--;
    }else{
        pl++;
    }
    if(v == 0 || mp[(cor){u,v-1,w}]){
        pl--;
    }else{
        pl++;
    }
    if(v == b-1 || mp[(cor){u,v+1,w}]){
        pl--;
    }else{
        pl++;
    }
    if(w == 0 || mp[(cor){u,v,w-1}]){
        pl--;
    }else{
        pl++;
    }
    if(w == c-1 || mp[(cor){u,v,w+1}]){
        pl--;
    }else{
        pl++;
    }
    mp[(cor){u,v,w}]++;
    return pl;
}

int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&n);
    ll res =  2*(a*b+b*c+c*a);
	rep(i,n){
        int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
        res += solve(u,v,w);
	}
    cout << res << "\n";
	return 0;
}