#include <bits/stdc++.h>
using namespace std;

template<typename T, T MOD>
class modint{
    using value_type = T;
public:
    value_type val;
    static modint e() noexcept {
        return modint(1);
    }
    static modint z() noexcept {
        return modint(0);
    }
    modint(const value_type& _val = 0) : val(_val){}
    modint& operator+=(modint& rhs) noexcept {
        this->val += rhs.val;
        this->val -= (this->val >= MOD) * MOD;
        return *this;
    }
    modint& operator-=(modint& rhs) noexcept {
        this->val += MOD - rhs.val;
        this->val -= (this->val >= MOD) * MOD;
        return *this;
    }
    modint& operator*=(modint& rhs) noexcept {
        this->val *= rhs.val;
        this->val %= MOD;
        return *this;
    }
};

template<typename T, T MOD>
modint<T, MOD> operator+(const modint<T, MOD>& a, const modint<T, MOD>& b){
    auto t = a.val + b.val;
    return modint<T, MOD>(t - (t >= MOD) * MOD);
}
template<typename T, T MOD>
modint<T, MOD> operator-(const modint<T, MOD>& a, const modint<T, MOD>& b){
    return a + modint<T, MOD>(MOD - b.val);
}
template<typename T, T MOD>
modint<T, MOD> operator*(const modint<T, MOD>& a, const modint<T, MOD>& b){
    return modint<T, MOD>(a.val * b.val % MOD);
}
template<typename T, T MOD>
ostream& operator<<(ostream& os, const modint<T, MOD>& mi){
    os << mi.val;
    return os;
}

template<typename Field, size_t n>
class square_matrix{
    using value_type = vector<vector<Field>>;
public:
    value_type val;
    explicit square_matrix(const value_type& _val = e()) : val(_val){}
    static value_type e() noexcept {
        value_type ret(n, vector<Field>(n, Field::z()));
        for(size_t i = 0; i < n; ++i)ret[i][i] = Field::e();
        return ret;
    }
    static value_type transpose(const value_type& a) noexcept {
        value_type ret(n, vector<Field>(n));
        for(unsigned long i = 0; i != n; ++i)
            for(unsigned long j = 0; j != n; ++j)
                ret[i][j] = a[j][i];
        return ret;
    }
    static value_type op(const value_type& a, const value_type& b) noexcept {
        auto bt = transpose(b);
        value_type ret(n, vector<Field>(n));
        for(unsigned long i = 0; i != n; ++i)
            for(unsigned long j = 0; j != n; ++j)
                ret[i][j] = inner_product(a[i].begin(), a[i].end(), bt[j].begin(), Field::z());
        return ret;
    }
    square_matrix& operator*=(const square_matrix& rhs) noexcept {
        this->val = op(this->val, rhs.val);
        return *this;
    }
};

template<typename Monoid>
Monoid pow(Monoid a, size_t n){
    Monoid ret{Monoid::e()};
    while(n){
        if(n & 1)ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

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

    modint<unsigned long, 1000000007> p{4};
    square_matrix<modint<unsigned long, 1000000007>, 10> a({{2,0,1,1,0,0,0,0,0,0},{0,4,0,0,0,0,0,0,0,0},{0,0,1,0,1,1,1,0,0,0},{2,0,0,1,0,0,0,1,0,0},{2,1,1,0,0,0,0,0,0,0},{0,1,0,0,0,0,0,1,1,1},{2,0,1,0,0,0,0,0,1,0},{0,1,1,0,0,1,1,0,0,0},{1,1,0,1,0,0,0,1,0,0},{1,1,1,1,0,0,0,0,0,0}});
    auto ans = (pow(p, N) - pow(a, N).val[0][1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256