// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <limits>

// contancer library
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <functional>

using ll = long long;
using ld = long double;

/* ----- class ----- */

template <class Cost = int, class Cap = int>
struct Edge {
    int from, to, rev;
    Cost cost;
    Cap cap;
    Edge(int from = -1, int to = -1, Cost cost = 1, Cap cap = 0, int rev = -1)
        : from(from), to(to), cost(cost), cap(cap), rev(rev){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int, class Cap = int>
class Graph {
public:
    int size;
    std::vector<std::vector<Edge<Cost, Cap>>> path;

    explicit Graph(int N = 0) : size(N), path(size) {}
    void span(int u, int v, Cost cost = 1, Cap cap = 0) {
        path[u].push_back(Edge<Cost, Cap>(u, v, cost, cap));
    }
    std::vector<Edge<Cost, Cap>> operator[](int v) const { return path[v]; }
};

/* ----- Output Functions for Debugging ----- */

template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T> v);
template <class T>
std::ostream& operator<<(std::ostream& os, std::set<T> v);
template <class L, class R>
std::ostream& operator<<(std::ostream& os, std::pair<L, R> p);
template <class K, class T>
std::ostream& operator<<(std::ostream& os, std::map<K, T> v);
template <class T>
std::ostream& operator<<(std::ostream& os, std::queue<T> q);
template <class T>
std::ostream& operator<<(std::ostream& os, std::priority_queue<T> q);
template <class T>
std::ostream& operator<<(std::ostream& os, std::priority_queue<T, std::vector<T>, std::greater<T>> q);
template <class T, class U>
std::ostream& operator<<(std::ostream& os, Edge<T, U> e);

template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}
template <class T>
std::ostream& operator<<(std::ostream& os, std::set<T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}
template <class L, class R>
std::ostream& operator<<(std::ostream& os, std::pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}
template <class K, class T>
std::ostream& operator<<(std::ostream& os, std::map<K, T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}
template <class T>
std::ostream& operator<<(std::ostream& os, std::queue<T> q) {
    os << "[";
    while (!q.empty()) {
        os << q.front() << ",";
        q.pop();
    }
    return os << "]";
}
template <class T>
std::ostream& operator<<(std::ostream& os, std::priority_queue<T> q) {
    os << "{";
    while (!q.empty()) {
        os << q.top() << ",";
        q.pop();
    }
    return os << "}";
}
template <class T>
std::ostream& operator<<(std::ostream& os, std::priority_queue<T, std::vector<T>, std::greater<T>> q) {
    os << "{";
    while (!q.empty()) {
        os << q.top() << ",";
        q.pop();
    }
    return os << "}";
}
template <class T, class U>
std::ostream& operator<<(std::ostream& os, Edge<T, U> e) {
    return os << "(" << e.from << "->" << e.to << ":" << e.cost << "," << e.cap << ")";
}

/* ----- Short Functions ----- */

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

/* ----- Constants ----- */

// const int INF = std::numeric_limits<int>::max();
// const ll INF = std::numeric_limits<ll>::max();
// const ld PI = acos(-1);
// const ld EPS = 1e-10;
// std::mt19937 mt(ll(time(0)));

class ModInt {
    using ll = long long;

public:
    int value;
    static int MOD;

    ModInt(ll value = 0) {
        this->value = (-MOD < value && value < MOD ? value : value % MOD);
        if (this->value < 0) this->value += MOD;
    }

    operator int() const noexcept { return this->value; }
    operator ll() const noexcept { return this->value; }

    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->value = x.value; }
        return *this;
    }

    bool operator==(const ModInt& x) const { return this->value == x.value; }
    bool operator!=(const ModInt& x) const { return !(*this == x); }

    ModInt operator+() const { return value; }
    ModInt operator-() const { return MOD - value; }
    ModInt operator~() const { return (*this) ^ ModInt(MOD - 2); }

    ModInt operator++() { return *this += 1; }
    ModInt operator--() { return *this -= 1; }

    ModInt operator++(int) {
        ModInt before = *this;
        ++(*this);
        return before;
    }
    ModInt operator--(int) {
        ModInt before = *this;
        --(*this);
        return before;
    }

    ModInt& operator+=(const ModInt& x) {
        int sum = this->value + x.value;
        return *this = (sum < MOD ? sum : sum - MOD);
    }
    ModInt& operator-=(const ModInt& x) {
        int diff = this->value - x.value;
        return *this = (diff >= 0 ? diff : diff + MOD);
    }
    ModInt& operator+=(int x) { return *this += ModInt(x); }
    ModInt& operator-=(int x) { return *this -= ModInt(x); }

    template <class T>
    ModInt& operator*=(const T& x) { return *this = ll(this->value) * ll(x) % MOD; }
    template <class T>
    ModInt& operator/=(const T& x) { return *this = (this->value % int(x) == 0 ? ModInt(this->value / int(x)) : *this * ~ModInt(x)); }
    template <class T>
    ModInt& operator^=(const T& x) {
        int n = int(x);
        ModInt b = *this;
        *this = 1;
        while (n > 0) {
            if (n & 1) *this *= b;
            n >>= 1;
            b *= b;
        }
        return *this;
    }

    template <class T>
    ModInt operator+(const T& b) const { return ModInt(*this) += b; }
    template <class T>
    ModInt operator-(const T& b) const { return ModInt(*this) -= b; }
    template <class T>
    ModInt operator*(const T& b) const { return ModInt(*this) *= b; }
    template <class T>
    ModInt operator/(const T& b) const { return ModInt(*this) /= b; }
    template <class T>
    ModInt operator^(const T& b) const { return ModInt(*this) ^= b; }
};

std::ostream& operator<<(std::ostream& os, const ModInt& x) { return os << x.value; }
std::istream& operator>>(std::istream& is, ModInt& x) { return is >> x.value; }

int ModInt::MOD = 1000000007;

using namespace std;

const string TAGC = "TAGC";

int main() {
    int N;
    cin >> N;

    auto dp = Vec<ModInt>(N + 1, 4, 4, 4, ModInt(0));
    dp[0][0][0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        int a[4];
        for (a[0] = 0; a[0] < 4; ++a[0]) {
            for (a[1] = 0; a[1] < 4; ++a[1]) {
                for (a[2] = 0; a[2] < 4; ++a[2]) {
                    for (a[3] = 0; a[3] < 4; ++a[3]) {
                        string S;
                        for (int j = 0; j < 4; ++j) S.push_back(TAGC[a[j]]);

                        bool judge = true;
                        if (S.substr(0, 3) == "AGC" || S.substr(1, 3) == "AGC") judge = false;
                        for (int j = 0; j < 3; ++j) {
                            swap(S[j], S[j + 1]);
                            if (S.substr(0, 3) == "AGC" || S.substr(1, 3) == "AGC") judge = false;
                            swap(S[j], S[j + 1]);
                        }

                        if (judge) {
                            dp[i][a[1]][a[2]][a[3]] += dp[i - 1][a[0]][a[1]][a[2]];
                        }
                    }
                }
            }
        }
    }

    ModInt ans = 0;
    int a[4];
    for (a[0] = 0; a[0] < 4; ++a[0]) {
        for (a[1] = 0; a[1] < 4; ++a[1]) {
            for (a[2] = 0; a[2] < 4; ++a[2]) {
                ans += dp[N][a[0]][a[1]][a[2]];
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384