Example

Input

2 2 2 1
0 0 0


Output

24
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int dx[6] = {1, 0, 0, -1, 0, 0};
const int dy[6] = {0, 1, 0, 0, -1, 0};
const int dz[6] = {0, 0, 1, 0, 0, -1};
ll A, B, C, N;
map<int, map<int, map<int, int>>> used;

bool contain(int x, int y, int z) {
  return x >= 0 && x < A && y >= 0 && y < B && z >= 0 && z < C;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> A >> B >> C >> N;
  ll ans = 2 * (A * B + B * C + C * A);
  for (int i = 0; i < N; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    used[x][y][z] = 1;
    for (int j = 0; j < 6; j++) {
      int nx = x + dx[j];
      int ny = y + dy[j];
      int nz = z + dz[j];
      if (!contain(nx, ny, nz) || used[nx][ny][nz]) {
        ans--;
      } else {
        ans++;
      }
    }
  }  
  cout << ans << endl;

  return 0;
}
