import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.math.BigInteger;

public class Euler818 {

    static class Mask {
        long lo; // bits 0..63
        long hi; // bits 64..80
    }

    static BigInteger binomInt(int n, int k) {
        if (k < 0 || k > n)
            return BigInteger.ZERO;
        k = Math.min(k, n - k);
        BigInteger res = BigInteger.ONE;
        for (int i = 1; i <= k; ++i) {
            res = res.multiply(BigInteger.valueOf(n - k + i)).divide(BigInteger.valueOf(i));
        }
        return res;
    }

    public static String solve() throws InterruptedException {
        int[][] coord = new int[81][4];
        for (int id = 0; id < 81; ++id) {
            int t = id;
            for (int d = 0; d < 4; ++d) {
                coord[id][d] = t % 3;
                t /= 3;
            }
        }
        int[] pow3 = { 1, 3, 9, 27 };

        HashSet<Integer> seen = new HashSet<>();
        ArrayList<int[]> lines = new ArrayList<>();

        for (int i = 0; i < 81; ++i) {
            for (int j = i + 1; j < 81; ++j) {
                int[] c = new int[4];
                for (int d = 0; d < 4; ++d) {
                    int s = coord[i][d] + coord[j][d];
                    c[d] = (3 - (s % 3)) % 3;
                }
                int k = 0;
                for (int d = 0; d < 4; ++d)
                    k += c[d] * pow3[d];

                int[] tri = { i, j, k };
                Arrays.sort(tri);
                int key = tri[0] | (tri[1] << 7) | (tri[2] << 14);
                if (seen.add(key)) {
                    lines.add(tri);
                }
            }
        }

        ArrayList<Mask> masks = new ArrayList<>();
        for (int[] tri : lines) {
            Mask m = new Mask();
            for (int p : tri) {
                if (p < 64)
                    m.lo |= (1L << p);
                else
                    m.hi |= (1L << (p - 64));
            }
            masks.add(m);
        }

        int L = masks.size();
        Mask fixed = masks.get(0);

        int threads = Math.max(1, Runtime.getRuntime().availableProcessors());
        long[][] threadCounts = new long[threads][13];
        Thread[] pool = new Thread[threads];
        int chunk = (L + threads - 1) / threads;

        for (int t = 0; t < threads; ++t) {
            final int tid = t;
            final int b = t * chunk;
            final int e = Math.min(L, b + chunk);

            pool[t] = new Thread(() -> {
                long[] local = new long[13];
                for (int l2 = b; l2 < e; ++l2) {
                    Mask m2 = masks.get(l2);
                    long u12Lo = fixed.lo | m2.lo;
                    long u12Hi = fixed.hi | m2.hi;

                    for (int l3 = 0; l3 < L; ++l3) {
                        Mask m3 = masks.get(l3);
                        long u123Lo = u12Lo | m3.lo;
                        long u123Hi = u12Hi | m3.hi;

                        for (int l4 = 0; l4 < L; ++l4) {
                            Mask m4 = masks.get(l4);
                            long uLo = u123Lo | m4.lo;
                            long uHi = u123Hi | m4.hi;
                            int sz = Long.bitCount(uLo) + Long.bitCount(uHi);
                            local[sz]++;
                        }
                    }
                }
                threadCounts[tid] = local;
            });
            pool[t].start();
        }

        for (int t = 0; t < threads; ++t) {
            pool[t].join();
        }

        long[] countsFixed = new long[13];
        for (int t = 0; t < threads; ++t) {
            for (int sz = 0; sz <= 12; ++sz) {
                countsFixed[sz] += threadCounts[t][sz];
            }
        }

        BigInteger[] N = new BigInteger[13];
        for (int sz = 0; sz <= 12; ++sz) {
            N[sz] = BigInteger.valueOf(countsFixed[sz]).multiply(BigInteger.valueOf(L));
        }

        BigInteger F12 = BigInteger.ZERO;
        int nTarget = 12;
        for (int m = 0; m <= 12; ++m) {
            if (N[m].signum() == 0 || nTarget < m)
                continue;
            BigInteger add = N[m].multiply(binomInt(81 - m, nTarget - m));
            F12 = F12.add(add);
        }

        return F12.toString();
    }

    public static void main(String[] args) throws InterruptedException {
        System.out.println(solve());
    }
}
