import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Euler997 {
    private static final int TARGET_X = 9;
    private static final int TARGET_Y = 10;
    private static final int TARGET_Z = 11;

    private static long pow2(int exponent) {
        if (exponent < 0 || exponent >= 63) {
            throw new IllegalArgumentException("exponent out of range");
        }
        return 1L << exponent;
    }

    private static long solveBox(int x, int y, int z) {
        return 3L * (pow2(x) + pow2(y) + pow2(z) - 4L) * pow2(x + y + z - 1);
    }

    private static int parity(int[] perm) {
        int inversions = 0;
        for (int i = 0; i < 3; ++i) {
            for (int j = i + 1; j < 3; ++j) {
                if (perm[i] > perm[j]) {
                    ++inversions;
                }
            }
        }
        return inversions % 2 == 0 ? 1 : -1;
    }

    private static int signedAxis(int axis, int sign) {
        return 2 * axis + (sign < 0 ? 1 : 0);
    }

    private static List<int[]> orientations() {
        List<int[]> result = new ArrayList<>();
        for (int a = 0; a < 3; ++a) {
            for (int b = 0; b < 3; ++b) {
                for (int c = 0; c < 3; ++c) {
                    if (a == b || a == c || b == c) {
                        continue;
                    }
                    int[] perm = {a, b, c};
                    for (int mask = 0; mask < 8; ++mask) {
                        int[] signs = new int[3];
                        for (int i = 0; i < 3; ++i) {
                            signs[i] = (mask & (1 << i)) == 0 ? 1 : -1;
                        }
                        if (parity(perm) * signs[0] * signs[1] * signs[2] != 1) {
                            continue;
                        }

                        int[] face = new int[6];
                        for (int axis = 0; axis < 3; ++axis) {
                            face[2 * axis] = signedAxis(perm[axis], signs[axis]);
                            face[2 * axis + 1] = signedAxis(perm[axis], -signs[axis]);
                        }
                        result.add(face);
                    }
                }
            }
        }
        return result;
    }

    private static long bruteCount(int x, int y, int z) {
        List<int[]> all = orientations();
        List<int[]> cells = new ArrayList<>();
        for (int k = 0; k < z; ++k) {
            for (int j = 0; j < y; ++j) {
                for (int i = 0; i < x; ++i) {
                    cells.add(new int[]{i, j, k});
                }
            }
        }

        int[] grid = new int[x * y * z];
        Arrays.fill(grid, -1);
        return search(0, x, y, cells, all, grid);
    }

    private static int index(int i, int j, int k, int x, int y) {
        return (k * y + j) * x + i;
    }

    private static long search(int position, int x, int y, List<int[]> cells, List<int[]> all, int[] grid) {
        if (position == cells.size()) {
            return 1L;
        }

        int[] cell = cells.get(position);
        int i = cell[0];
        int j = cell[1];
        int k = cell[2];
        long total = 0L;

        for (int o = 0; o < all.size(); ++o) {
            int[] current = all.get(o);
            if (i > 0) {
                int[] previous = all.get(grid[index(i - 1, j, k, x, y)]);
                if (previous[0] != current[1]) {
                    continue;
                }
            }
            if (j > 0) {
                int[] previous = all.get(grid[index(i, j - 1, k, x, y)]);
                if (previous[2] != current[3]) {
                    continue;
                }
            }
            if (k > 0) {
                int[] previous = all.get(grid[index(i, j, k - 1, x, y)]);
                if (previous[4] != current[5]) {
                    continue;
                }
            }

            grid[index(i, j, k, x, y)] = o;
            total += search(position + 1, x, y, cells, all, grid);
            grid[index(i, j, k, x, y)] = -1;
        }
        return total;
    }

    private static void runCheckpoints() {
        assert orientations().size() == 24;
        assert solveBox(1, 1, 1) == 24L;
        assert solveBox(2, 3, 4) == 18_432L;
        assert solveBox(1, 1, 2) == bruteCount(1, 1, 2);
        assert solveBox(1, 2, 2) == bruteCount(1, 2, 2);
        assert solveBox(2, 2, 1) == bruteCount(2, 2, 1);
        assert solveBox(2, 2, 2) == bruteCount(2, 2, 2);
    }

    public static void main(String[] args) {
        runCheckpoints();
        System.out.println(solveBox(TARGET_X, TARGET_Y, TARGET_Z));
    }
}
