#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; ll n; ll a[10][10] = { 1,1,1,1,1,1,1,0,0,1, 0,1,1,0,0,1,1,0,1,1, 0,1,1,0,1,0,0,0,1,1, 0,0,0,1,1,1,0,0,1,1, 0,0,0,0,1,0,0,0,0,1, 0,1,0,1,0,1,1,0,1,1, 0,1,0,0,0,1,1,0,1,1, 0,0,1,1,0,0,0,1,1,0, 0,0,0,0,0,0,0,0,1,0, 0,1,1,1,0,1,1,1,1,1 }, b[10][10], c[10][10]; void merge(ll (&a1)[10][10], ll (&a2)[10][10], ll (&a3)[10][10]){ FOR(i, 0, 10){ FOR(j, 0, 10){ ll d = 0; FOR(k, 0, 10){ d += a1[i][k] * a2[k][j] % mod; } c[i][j] = d % mod; } } FOR(i, 0, 10){ FOR(j, 0, 10){ a3[i][j] = c[i][j]; } } } main(){ cin.tie(0); ios::sync_with_stdio(false); FOR(i, 0, 10)b[i][i] = 1; cin >> n; n++; while(n > 0){ if(n & 1){ merge(b, a, b); } merge(a, a, a); n >>= 1; } cout << b[0][8] << endl; }