using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    class AGCT
    {
        public BigInteger sum;
        public BigInteger ag;
        public BigInteger ac;
        public BigInteger ga;

        public BigInteger three;
    }
    public class Program
    {
        public object Calc()
        {
            const int mod = 1000000007;

            var N = consoleReader.Int32();
            var result = new AGCT[N + 1];
            result[0] = new AGCT { sum = 1 };
            result[1] = new AGCT { sum = 4 };
            result[2] = new AGCT { sum = 16, ag = 1, ac = 1, ga = 1 };
            result[3] = new AGCT { sum = 61, ag = 4, ac = 3, ga = 4, three = 3 };

            for (int i = 4; i <= N; i++)
            {
                var next = new AGCT();

                next.sum = 4 * result[i - 1].sum - result[i - 1].ag - result[i - 1].ac - result[i - 1].ga - result[i - 1].three;

                next.ag = result[i - 2].sum ;
                next.ac = 3 * result[i - 3].sum - result[i - 3].ag - result[i - 3].ga - result[i - 3].three;
                next.ga = result[i - 2].sum - result[i - 2].ac;
                next.three = 3 * result[i - 3].sum;

                result[i] = next;
            }


            return result[N].sum % mod;
        }

        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine();
        public int Int32() => int.Parse(String());
        public long Int64() => long.Parse(String());
        public ulong UInt64() => ulong.Parse(String());
        public double Double() => double.Parse(String());
        public string[] Split() => String().Split().ToArray();
        public int[] SplitInt32() => String().Split().Select(s => int.Parse(s)).ToArray();
        public long[] SplitInt64() => String().Split().Select(s => long.Parse(s)).ToArray();
        public ulong[] SplitUInt64() => String().Split().Select(s => ulong.Parse(s)).ToArray();
        public double[] SplitDouble() => String().Split().Select(s => double.Parse(s)).ToArray();

        public IEnumerable<string> Repeat(int count)
        {
            for (int i = 0; i < count; i++)
                yield return String();
        }
        public IEnumerable<int> RepeatInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int32();
        }
        public IEnumerable<long> RepeatInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int64();
        }
        public IEnumerable<string[]> RepeatSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Split();
        }
        public IEnumerable<int[]> RepeatSplitInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return SplitInt32();
        }
    }
    static class DicExt
    {
        public static V GetOrDefault<K, V>(this Dictionary<K, V> dic, K key, V defaultValue = default(V))
        {
            V val;
            return dic.TryGetValue(key, out val) ? val : defaultValue;
        }
    }
}


Measured memory_bytes: 13524