N = gets.to_i
M = 1E9.to_i + 7
PT = %w(A C G T).repeated_permutation(4).select do |a|
  4.times.any?{|i| s = a.join; s[i - 1], s[i] = s[i], s[i - 1] unless i.zero?; s.include?("AGC")}
end.map(&:join)

def go(n, s)
  return 1 if n == N
  @m ||= Array.new(N + 1){{}}
  @m[n][s] ||= %w(A C G T).inject(0) do |r, c|
    t = s + c
    PT.include?(t) ? r : (r + go(n + 1, t[1, 3])) % M
  end
end

puts go(0, 'TTT')