N = gets.to_i
# [{}] * N だとバグる
DP = Array.new(N) { {} }

def dfs(k, his)
  return 1 if k == N
  return DP[k][his] if DP[k].include? his
  DP[k][his] = 'ACGT'.chars
    .select {|c|
      his + c !~ /AGC|GAC|ACG|A.GC|AG.C/
    }.map {|c|
      dfs(k + 1, his[1..-1] + c)
  }.inject(:+) % (10 ** 9 + 7)
end

p dfs(0, 'TTT')