@n = gets.to_i
@memo = Array.new(@n+1) {Hash.new}
M = 10 ** 9 + 7

def calc(i, str)
    return @memo[i][str] if @memo[i][str]

    if i == @n
        return @memo[i][str] = str["AGC"] || str["GAC"] || str["ACG"] ? 0 : 1
    end

    r = 0
    "ACGT".each_char do |c|
        x = str + c

        if i > 2
            b = !3.times.any? do |j|
                t = x.dup
                t[j], t[j+1] = t[j+1], t[j]
                t["AGC"]
            end
            r += calc(i + 1, x[1, 3]) if b && !x["AGC"]
        else
            r += calc(i + 1, x)
        end
    end

    @memo[i][str] = r % M
end

p calc(0, "")
#p @memo