#include #define show(x) cout << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; template ostream& operator<<(ostream& os, const vector& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template constexpr T INF = numeric_limits::max() / 100; constexpr int NUM = 10; using Mat = array, NUM>; Mat operator*(const Mat& m1, const Mat& m2) { Mat m; for (auto i = 0; i < NUM; i++) { for (auto j = 0; j < NUM; j++) { m[i][j] = 0; for (auto k = 0; k < NUM; k++) { m[i][j] += m1[i][k] * m2[k][j]; m[i][j] = m[i][j] % MOD; } } } return m; } Mat unit() { Mat mat; for (auto i = 0; i < NUM; i++) { for (auto j = 0; j < NUM; j++) { if (i == j) { mat[i][j] = 1; } else { mat[i][j] = 0; } } } return mat; } Mat power(const Mat& m, const ll n) { if (n == 0) { return unit(); } if (n % 2 == 1) { return m * power(m, n - 1); } else { const Mat p = power(m, n / 2); return p * p; } } int main() { ll N; cin >> N; const Mat m{{ {1, 0, 1, 1, 1, 1, 1, 1, 1, 0}, {0, 1, 0, 1, 0, 1, 0, 0, 0, 1}, {0, 0, 1, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 1, 1, 0, 0, 1, 0, 1, 1}, {0, 0, 0, 0, 1, 0, 1, 1, 1, 1}, {0, 0, 1, 0, 0, 1, 0, 1, 1, 1}, {0, 0, 0, 1, 1, 0, 1, 1, 1, 1}, {0, 0, 0, 0, 1, 1, 1, 1, 1, 1}, {0, 1, 0, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1} }}; const Mat p = power(m, N + 1); cout << p[0][NUM - 1] << endl; return 0; }