using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_122
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long mask = 1000000000 + 7;
            long[] all = new long[n];
            all[0] = 4;
            for(int i = 1; i < n; i++)
            {
                all[i] = all[i - 1] * 4;
                all[i] %= mask;
            }
            List<int> ng = new List<int>();
            for (int i = 0; i <= 4; i++)
            {
                ng.Add(i * 1000 + 132);
                ng.Add(i * 1000 + 123);
                ng.Add(i * 1000 + 312);
                if (i > 0)
                {
                    ng.Add(i * 100 + 1032);
                    ng.Add(i * 10 + 1302);
                }
            }
            var dict = new Dictionary<int, long>();
            dict.Add(1, 1);
            dict.Add(2, 1);
            dict.Add(3, 1);
            dict.Add(4, 1);
            for (int i = 1; i < n; i++)
            {
                var next = new Dictionary<int, long>();
                foreach (int key in dict.Keys)
                {
                    for (int j = 1; j <= 4; j++)
                    {
                        int val = (key % 1000)*10 + j;
                        bool isNg = false;
                        for (int k = 0; k < ng.Count; k++)
                        {
                            if (val == ng[k])
                            {
                                isNg = true;
                                break;
                            }
                        }
                        if (!isNg)
                        {
                            if (!next.ContainsKey(val))
                            {
                                next.Add(val, 0);
                            }
                            next[val] += dict[key];
                            next[val] %= mask;
                        }
                    }
                }
                dict = next;
            }
            long res = 0;
            foreach(int key in dict.Keys)
            {
                res += dict[key];
                res %= mask;
            }
            WriteLine(res);
            /*
            long[,,,] dp = new long[n, 4, 4, 4];
            for(int i = 0; i < 4; i++)
            {
                dp[2, 0, 2, 1] = 1;
                dp[2, 0, 1, 2] = 1;
                dp[2, 2, 0, 1] = 1;
            }
            for(int i = 3; i < n; i++)
            {
                for(int i1 = 0; i1 < 4; i1++)
                {
                    for (int i2 = 0; i2 < 4; i2++)
                    {
                        for (int i3 = 0; i3 < 4; i3++)
                        {
                            dp[i, i2, i3, 0] = dp[i - 1, i1, i2, i3];
                            dp[i, i2, i3, 1] = dp[i - 1, i1, i2, i3];
                            dp[i, i2, i3, 2] = dp[i - 1, i1, i2, i3];
                            dp[i, i2, i3, 3] = dp[i - 1, i1, i2, i3];
                        }
                    }
                }
                long tmp1 = all[i - 1];
                long tmp2 = all[i - 1];
                long tmp3 = all[i - 1];
                for(int j = 0; j < 4; j++)
                {
                    tmp1-= dp[i - 1, j, 0, 2];
                    tmp2-= dp[i - 1, j, 0, 1];
                    tmp3-= dp[i - 1, j, 2, 0];
                }
                while (tmp1 < 0) tmp1 += mask;
                while (tmp2 < 0) tmp2 += mask;
                while (tmp3 < 0) tmp3 += mask;
                dp[i, 0, 2, 1] += tmp1;
                dp[i, 0, 2, 1] %= mask;
                dp[i, 0, 1, 2] += tmp2;
                dp[i, 0, 1, 2] %= mask;
                dp[i, 2, 0, 1] += tmp3;
                dp[i, 2, 0, 1] %= mask;

                long tmp4 = all[i - 1];
                long tmp5 = all[i - 1];
                for (int j = 0; j < 4; j++)
                {
                    dp[i, j, 2, 1] += all[i - 1] - dp[i - 1, 0, j, 2];
                    while (dp[i, j, 2, 1] < 0) dp[i, j, 2, 1] += mask;
                    dp[i, j, 2, 1] %= mask;
                    dp[i, 2, j, 1] += all[i - 1] - dp[i - 1, 0, 2, j];
                    while (dp[i, 2, j, 1] < 0) dp[i, 2, j, 1] += mask;
                    dp[i, 2, j, 1] %= mask;
                }
            }
            long res = 0;
            for(int j1=0;j1<4;j1++)
            {
                for (int j2 = 0; j2 < 4; j2++)
                {
                    for (int j3 = 0; j3 < 4; j3++)
                    {
                        res -= dp[n - 1, j1, j2, j3];
                    }
                }
            }
            res += all[n - 1];
            while (res < 0) res += mask;
            res %= mask;
            WriteLine(res);
            */
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 12384