#include using namespace std; const long mod = 1000000007; using Mat = vector>; int size = 10; Mat mat = { { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, { 0, 1, 1, 1, 0, 0, 0, 1, 0, 1 }, { 0, 1, 1, 1, 1, 1, 0, 0, 0, 1 }, { 0, 1, 1, 1, 1, 1, 1, 0, 1, 1 }, { 0, 0, 1, 1, 1, 1, 0, 0, 0, 1 }, { 0, 0, 1, 1, 1, 1, 1, 0, 0, 1 }, { 0, 0, 0, 1, 0, 1, 1, 1, 0, 1 }, { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 }, { 0, 1, 0, 0, 0, 0, 1, 0, 1, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } }; Mat zero() { return Mat(size, vector(size)); } Mat id() { Mat ret = zero(); for (int i = 0; i < size; ++i) { ret[i][i] = 1; } return ret; } Mat mul(Mat a, Mat b) { Mat ret = zero(); for (int i = 0; i < size; ++i) { for (int k = 0; k < size; ++k) { for (int j = 0; j < size; ++j) { ret[i][j] = (ret[i][j] + a[i][k] * b[k][j]) % mod; } } } return ret; } Mat power(Mat a, long ex) { Mat ret = id(); Mat base = a; while (ex > 0) { if (ex & 1) ret = mul(ret, base); base = mul(base, base); ex >>= 1; } return ret; } long n; int main() { cin >> n; auto res = power(mat, n + 1); cout << res[0][size - 1] << endl; }