unittest
{
	assert( [ "3" ].parse.expand.solve == 61 );
	assert( [ "4" ].parse.expand.solve == 230 );
	assert( [ "100" ].parse.expand.solve == 388130742 );
}



import std.conv;
import std.functional;
import std.range;
import std.regex;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	return dfs( n, "" );
}

long dfs( long n, string ps )
{
	const MOD = 10L ^^ 9 + 7;
	
	if( n <= 0 ) return 1L;
	
	auto ans = 0L;
	foreach( c; [ "A", "C", "G", "T" ] )
	{
		auto nps = ps ~ c;
		if( matchFirst( nps, ".?A.?G.?C.?|.?ACG.?|.?GAC.?" ).empty )
		{
			if( nps.length <= 3 ) ans = ( ans + memoize!dfs( n - 1, nps ) ) % MOD;
			else                  ans = ( ans + memoize!dfs( n - 1, nps[ $ - 3 .. $ ] ) ) % MOD;
		}
	}
	return ans;
}
