Example

Input

2 2 2 1
0 0 0


Output

24
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(){
  long long int a, b, c, n;
  cin >> a >> b >> c >> n;
  map<vector<int>,int> M;
  int dx[] = {1,0,0,-1,0,0}, dy[] = {0,1,0,0,-1,0}, dz[] = {0,0,1,0,0,-1};
  long long int ans = 2*(a*b + b*c + c*a);
  for(int i = 0; i < n; ++i){
    vector<int> t(3);
    cin >> t[0] >> t[1] >> t[2];
    ++M[t];
    int d = 0;
    for(int j = 0; j < 6; ++j){
      vector<int> t_ = t;
      t_[0] += dx[j];
      t_[1] += dy[j];
      t_[2] += dz[j];
      if(t_[0] >= a || t_[1] >= b || t_[2] >= c ||
         t_[0] < 0 || t_[1] < 0 || t_[2] < 0 || M[t_] == 1){
        --d;
      }else{
        ++d;
      }
    }
    ans += d;
  }
  cout << ans << endl;
  return 0;
}

