#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug { 
    ($($a: expr),*) => { 
        println!(concat!($(stringify!($a)," = {:?}, "),*), $($a),*);
    } 
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn solve() {
    let n = get!(usize);

    let mut dp = vec![vec![vec![vec![0;4];4];4]; n+1];

    let mo = 1_000_000_007;
    dp[0][3][3][3] = 1;

    for i in 0..n {
        for a in 0..4 { //before 3
            for b in 0..4 { //before 2
                for c in 0..4 { //before 1
                    for d in 0..4 { //current
                        //ACGT => 0123
                        //.AGC
                        //.ACG
                        //.GAC
                        //A.GC
                        //AG.C
                        if (b == 0 && c == 1 && d == 2) //.ACG
                            || (b == 2 && c == 0 && d == 1) //.GAC
                            || (a == 0 && c == 2 && d == 1) //A.GC
                            || (a == 0 && b == 2 && d == 1) //AG.C
                            || (b == 0 && c == 2 && d == 1) /*.AGC*/ {
                            continue;
                        }

                        dp[i+1][d][c][b] += dp[i][c][b][a];
                        dp[i+1][d][c][b] %= mo;
                    }
                }
            }
        }
    } 
    
    let mut res = 0u64;
    for a in 0..4 {
        for b in  0..4 {
            for c in 0..4 {
                res += dp[n][a][b][c];
                res %= mo;
            }
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 8572