#include #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define FORR(i,a,b) for (int i=(a);i>=(b);i--) #define pb push_back using namespace std; typedef long long ll; typedef pair pii; typedef vector vi; typedef set si; const int inf = 1e9; const int mod = 1e9+7; const int s = 7; ll n; ll a[s][s] = { 0,1,0,1,0,1,0, 0,0,0,1,0,1,0, 0,1,0,0,0,1,0, 0,0,1,0,0,0,0, 0,1,0,1,0,0,0, 0,0,0,0,0,0,1, 0,0,0,0,1,0,0 }, b[s][s], c[s][s]; void merge(ll (&a1)[s][s], ll (&a2)[s][s]){ FOR(i, 0, s){ FOR(j, 0, s){ ll d = 0; FOR(k, 0, s){ d += a1[i][k] * a2[k][j] % mod; } c[i][j] = d % mod; } } FOR(i, 0, s){ FOR(j, 0, s){ a1[i][j] = c[i][j]; } } } main(){ cin.tie(0); ios::sync_with_stdio(false); FOR(i, 0, s)b[i][i] = 1; cin >> n; while(n > 0){ if(n & 1){ merge(b, a); } merge(a, a); n >>= 1; } ll ans = b[0][1] + b[0][2] + b[0][4]; ans %= mod; cout << ans << endl; }