/*    ∫ ∫ ∫    ノヽ   (_  )  (_    ) (______ )  ヽ(´・ω・)ノ     |  /    UU */ #pragma region macro #include typedef long long int64; using namespace std; typedef vector vi; const int MOD = (int)1e9 + 7; const int64 INF = 1LL << 62; const int inf = 1<<30; const char bn = '\n'; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b ostream& operator<<(ostream& os, const vector &V){ int N = V.size(); REP(i,N){ os << V[i]; if (i!=N-1) os << " "; } os << "\n"; return os; } template ostream& operator<<(ostream& os, pair const&P){ os << "("; os << P.first; os << " , "; os << P.second; os << ")"; return os; } template ostream& operator<<(ostream& os, tuple const& P){ os << "("; os << get<0>(P); os << ", "; os << get<1>(P); os << ", "; os << get<2>(P); os << ")"; return os; } template ostream& operator<<(ostream& os, set &S){ auto it=S.begin(); while(it!=S.end()){ os << *it; os << " "; it++; } os << "\n"; return os; } template ostream& operator<<(ostream& os, deque &q){ for(auto it=q.begin();it ostream& operator<<(ostream& os, map const&M){ for(auto e:M){ os<> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)}; #pragma endregion //fixed< struct Matrix{ vector> matrix_data; Matrix(){} Matrix(const vector>& matrix_data):matrix_data(matrix_data){} //単位行列 Matrix Identity(size_t N){ vector> res(N,vector(N,0)); for(size_t i=0; i(res); } //累乗O(N^3 log k) Matrix power(int64 k){ Matrix res = Matrix::Identity(matrix_data.size()); Matrix tmp = *this; while(k){ if(k&1){res *= tmp;} tmp *= tmp; k >>= 1LL; } return res; } //T det(){} //Matrix inv(){} 逆行列求めるやつあっても面白いね。正則(⇔det(A)!=0)じゃないといけないけど。 }; template Matrix operator*(const Matrix& mat_a, const Matrix& mat_b){ size_t A = mat_a.matrix_data.size(); size_t B = mat_b.matrix_data.size(); assert(B > 0); size_t C = mat_b.matrix_data[0].size(); Matrix res(vector>(A,vector(C,0))); for(size_t i=0; i Matrix& operator*=(Matrix& mat_a, Matrix& mat_b){ mat_a = mat_a*mat_b; return mat_a; } template ostream& operator<<(ostream& os, const Matrix& M){ os << M.matrix_data; return os; } int64 pow(int a,int b,int mod){ vector bit; for(b=b;b>0;b>>=1){ bit.push_back(b&1); } vector fac(bit.size()); fac[0] = a; int64 res = 1; for(int i=1;i= MOD) x -= MOD; return *this; } mint& operator-=(const mint a) { if ((x += MOD-a.x) >= MOD) x -= MOD; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this; } mint operator+(const mint a) const { mint res(*this); return res+=a; } mint operator-(const mint a) const { mint res(*this); return res-=a; } mint operator*(const mint a) const { mint res(*this); return res*=a; } mint pow(int64 t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime MOD mint inv() const { return pow(MOD-2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res/=a; } }; ostream& operator<<(ostream& os, mint a){ os << a.x; return os; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int64 N; cin >> N; vector> A = { vector(6,mint(1)/6), {1,0,0,0,0,0}, {0,1,0,0,0,0}, {0,0,1,0,0,0}, {0,0,0,1,0,0}, {0,0,0,0,1,0}, }; Matrix B(A); Matrix V({{1,0,0,0,0,0}}); auto VB = V*B.power(N); mint ans = VB.matrix_data[0][0]; cout << ans << endl; }