Example

Input

2 2 2 1
0 0 0


Output

24
#include <iostream>
using namespace std;
 
typedef long long ll;
 
ll A, B, C, N;
struct block{
  ll x,y,z;
};
 
#include <vector>
 
ll surfaces;
vector<block> deleted;
 
ll block_index(const vector<block> & v, ll x, ll y, ll z){
  for(ll i=0; i< v.size(); ++i){
    auto & block = v[i];
    if(block.x == x && block.y == y && block.z == z) return i;
  }
  return -1;
}
 
bool exist(ll x, ll y, ll z){
  if(block_index(deleted, x, y, z) != -1) return false;
  if( 0 <= x && x < A && 0 <= y && y < B && 0 <= z && z < C) return true;
  return false;
}
 
int main(){
  cin >> A >> B >> C >> N;
  surfaces = A * B * 2 + A * C * 2 + B * C * 2;
  for(int i = 0; i < N; ++i){
    ll x,y,z;
    cin >> x >> y >> z;
    
    int surface = 0;
    for(int d : {-1, 1}) if(!exist(x+d,y,z)) surface++;
    for(int d : {-1, 1}) if(!exist(x,y+d,z)) surface++;
    for(int d : {-1, 1}) if(!exist(x,y,z+d)) surface++;
 
    surfaces += 6 - surface * 2;
    deleted.push_back({x,y,z});
  }
 
  cout << surfaces << endl;
}