Example

Input

2 2 2 1
0 0 0


Output

24
#include<iostream>
#include<tuple>
#include<set>
using namespace std;

typedef tuple<int,int,int> T;

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

int main(){
  long long a, b, c;
  int n;
  cin >> a >> b >> c >> n;

  long long ans = 2 * (a * b + b * c + c * a);
  set<T> t;
  for(int i = 0; i < n; i++){
      int x, y, z;
      cin >> x >> y >> z;
      t.emplace(x,y,z);
  }

  for(auto i : t){
    ans += 6;
    int x, y, z;
    tie(x, y, z) = i;

    int cnt = 0;
    if(x == 0) ans-=2;
    if(x == a - 1) ans -= 2;
    if(y == 0) ans-=2;
    if(y == b - 1) ans -= 2;
    if(z == 0) ans-=2;
    if(z == c - 1) ans -= 2;

    for(int j = 0; j < 6; j++){
      int nx = x + dx[j];
      int ny = y + dy[j];
      int nz = z + dz[j];
      if(t.count(T(nx,ny,nz))) ans--;
    }
  }
  cout << ans << endl;

}

