#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (unsigned long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (unsigned long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll p = 1000000007ll;
constexpr int GENOM_EMPTY = 0;
constexpr int GENOM_A = 1;
constexpr int GENOM_T = 2;
constexpr int GENOM_G = 3;
constexpr int GENOM_C = 4;

vector<vector<ll>> mltm(const vector<vector<ll>> &a, const vector<vector<ll>> &b) {
    ull m = a.size(), q = b.size(), r = b[0].size();
    vector<vector<ll>> c(m, vector<ll>(r, 0));
    REP(i, m) REP(j, r) {
        REP(k, m) {
            c[i][j] += a[i][k] * b[k][j] % p;
            c[i][j] %= p;
        }
    }
    return c;
}

vector<vector<ll>> powm(const vector<vector<ll>> &a, const ll n) {
    if (n == 0) {
        vector<vector<ll>> r(a.size(), vector<ll>(a[0].size(), 0));
        REP(i, a.size()) r[i][i] = 1;
        return r;
    } else if (n == 1) {
        return a;
    } else if (n % 2 == 0) {
        vector<vector<ll>> t = powm(a, n/2);
        return mltm(t, t);
    } else if (n % 2 == 1) {
        vector<vector<ll>> t = powm(a, n/2);
        return mltm(mltm(t, t), a);
    }
}

// 処理内容
int main() {
    
    ll n;
    cin >> n;

    vector<vector<ll>> t(125, vector<ll>(125, 0));
    REP(j, 125) {
        int pre3 = j / 25;
        int pre2 = (j % 25) / 5;
        int pre1 = j % 5;
        int next = (j % 25) * 5;
        t[next + GENOM_A][j]++;
        t[next + GENOM_T][j]++;
        if (!(
            pre2 == GENOM_A &&
            pre1 == GENOM_C
        )) {
            t[next + GENOM_G][j]++;
        }
        if (!(
            pre2 == GENOM_G &&
            pre1 == GENOM_A
        ) && !(
            pre2 == GENOM_A &&
            pre1 == GENOM_G
        ) && !(
            pre3 == GENOM_A &&
            pre2 != GENOM_EMPTY &&
            pre1 == GENOM_G
        ) && !(
            pre3 == GENOM_A &&
            pre2 == GENOM_G &&
            pre1 != GENOM_EMPTY
        )) {
            t[next + GENOM_C][j]++;
        }
    }

    vector<vector<ll>> x(125, vector<ll>(1, 0));
    x[0][0] = 1;
    
    vector<vector<ll>> xr = mltm(powm(t, n), x);
    ll ans = 0;
    REP(i, 125) {
        ans += xr[i][0];
        ans %= p;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 772