Example

Input

2 2 2 1
0 0 0


Output

24
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;
typedef long long int lli;
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};

int main(){
	lli a,b,c;
	int n;
	cin >> a >> b >> c >> n;
	
	lli s = 2*(a*b +b*c +c*a);
	set<pair<pair<int,int>,int> > del;
	for(int i=0; i<n; i++){
		int count=0;
		int x,y,z;
		cin >> x >> y >> z;
		for(int d=0; d<6; d++){
			int nx=x+dx[d], ny=y+dy[d], nz=z+dz[d];
			if(nx<0 || ny<0 || nz<0 || nx>=a || ny>=b || nz>=c) continue;
			if(del.find(make_pair(make_pair(nx,ny),nz)) != del.end()) continue;
			count++;
		}
		s += 2*count -6;
		del.insert(make_pair(make_pair(x,y),z));
	}
	cout << s << endl;
	return 0;
}