#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

#[allow(unused_macros)]
macro_rules! map {
    ( $ value : expr ; $ ( $ key : expr ) ,* ) => { { IndexMap ( vec ! [ $ ( $ key ) ,* ] . into_iter ( ) . map ( | k | ( k , $ value ) ) . collect ::< std :: collections :: HashMap < _ , _ >> ( ) ) } };
    ( $ value : expr ; $ ( $ ( $ key : expr ) ,* ) ;* ) => { map ! ( $ ( $ ( $ key ) ,* ) ;* => $ value ) };
    ( $ ( $ head : expr ) ,*; $ ( $ ( $ tail : expr ) ,* ) ;* => $ init : expr ) => { map ! [ map ! ( $ ( $ ( $ tail ) ,* ) ;* => $ init ) ; $ ( $ head ) ,* ] };
    ( $ ( $ head : expr ) ,* => $ init : expr ) => { map ! [ $ init ; $ ( $ head ) ,* ] };
}
#[derive(Debug, Clone)]
struct IndexMap<K: Eq + std::hash::Hash, V>(pub std::collections::HashMap<K, V>);
impl<K, V> std::ops::Deref for IndexMap<K, V>
where
    K: Eq + std::hash::Hash,
{
    type Target = std::collections::HashMap<K, V>;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[allow(dead_code)]
impl<'a, K, V, Q: ?Sized> std::ops::Index<&'a Q> for IndexMap<K, V>
where
    K: std::borrow::Borrow<Q> + Eq + std::hash::Hash,
    Q: Ord + Eq + std::hash::Hash,
{
    type Output = V;
    fn index(&self, index: &Q) -> &V {
        self.0.get(index).expect("no entry found for key")
    }
}
#[allow(dead_code)]
impl<'a, K, V, Q: ?Sized> std::ops::IndexMut<&'a Q> for IndexMap<K, V>
where
    K: std::borrow::Borrow<Q> + Eq + std::hash::Hash,
    Q: Ord + Eq + std::hash::Hash,
{
    fn index_mut(&mut self, index: &Q) -> &mut V {
        self.0.get_mut(index).expect("no entry found for key")
    }
}

fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut dp = vec![map![0u64;'A','G','C','T','_';'A','G','C','T','_';'A','G','C','T','_']; n + 1];
    dp[0][&'_'][&'_'][&'_'] = 1;
    for p in 0..n {
        for i in "AGCT_".chars() {
            for j in "AGCT_".chars() {
                for k in "AGCT_".chars() {
                    for l in "AGCT".chars() {
                        if (i, j, l) == ('A', 'G', 'C') {
                            continue;
                        }
                        if (i, k, l) == ('A', 'G', 'C') {
                            continue;
                        }
                        if (j, k, l) == ('A', 'G', 'C') {
                            continue;
                        }
                        if (j, k, l) == ('G', 'A', 'C') {
                            continue;
                        }
                        if (j, k, l) == ('A', 'C', 'G') {
                            continue;
                        }
                        dp[p + 1][&j][&k][&l] += dp[p][&i][&j][&k];
                        dp[p + 1][&j][&k][&l] %= M;
                    }
                }
            }
        }
    }
    let mut ret = 0u64;
    for i in "AGCT".chars() {
        for j in "AGCT".chars() {
            for k in "AGCT".chars() {
                ret += dp[n][&i][&j][&k];
                ret %= M;
            }
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 6396