Problem:
Score : 400 points

Problem Statement

You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:

The string does not contain characters other than A, C, G and T.

The string does not contain AGC as a substring.

The condition above cannot be violated by swapping two adjacent characters once.

Notes

A substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.

For example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.

Constraints

3 \leq N \leq 100

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of strings of length N that satisfy the following conditions, modulo 10^9+7.

Sample Input 1

3

Sample Output 1

61

There are 4^3 = 64 strings of length 3 that do not contain characters other than A, C, G and T. Among them, only AGC, ACG and GAC violate the condition, so the answer is 64 - 3 = 61.

Sample Input 2

4

Sample Output 2

230

Sample Input 3

100

Sample Output 3

388130742

Be sure to print the number of strings modulo 10^9+7.

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


map<char,ll>mp;


ll dp[102][5][5][5][5];

ll n;

string str;


ll ok(ll a,ll b,ll c,ll d)
{
   ll sum=0,num=0;

   sum=a;

   sum*=10;

   sum+=b;

   sum*=10;

   sum+=c;

   sum*=10;

   sum+=d;



   num=b;

   num*=10;

   num+=c;

   num*=10;

   num+=d;


   if(sum==123 || sum==132 || sum==213 ||
      sum==1243 || sum==1423 || sum==1223 || sum==1323)
        return -1;

   if(num==123 || num==132 || num==213)return -1;


      if(num<100)return 0;

      else return 1;



}

ll call(ll pos,ll a,ll b,ll c,ll d)
{

      if(ok(a,b,c,d)==-1)return 0;

      if(pos==n)
      {
          if(ok(a,b,c,d)==1)return 1;

          else return 0;
      }

      ll &ret=dp[pos][a][b][c][d];


      if(~ret)return ret;


      ret=0;

      for(ll i=0; i<4; i++)
      {
          ret=(ret+call(pos+1,b,c,d,mp[str[i]]))%Mod;
      }


        return ret%Mod;




}

int main()
{

   fastread();

   ll i,j,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;



      cin>>n;

      memset(dp,-1,sizeof(dp));

   str="AGCT";

    mp['A']=1;

    mp['G']=2;

    mp['C']=3;

    mp['T']=4;


    cout<<call(0,0,0,0,0)<<endl;
















}