#include #include #include template struct mod_int{ int64_t val; constexpr mod_int():val(0){} constexpr mod_int(int64_t x)noexcept:val(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD){} constexpr int64_t value()const noexcept{return val;} constexpr int64_t get_MOD()const noexcept{return MOD;} constexpr mod_int operator+(mod_int const& rhs){ return mod_int(*this)+=rhs; } constexpr mod_int operator-(mod_int const& rhs){ return mod_int(*this)-=rhs; } constexpr mod_int operator*(mod_int const& rhs){ return mod_int(*this)*=rhs; } constexpr mod_int operator/(mod_int const& rhs){ return mod_int(*this)/=rhs; } constexpr mod_int &operator+=(mod_int const& rhs)noexcept{ val += rhs.val; if(val>=MOD)val-=MOD; return *this; } constexpr mod_int &operator-=(mod_int const& rhs)noexcept{ if(val(mod_int const& rhs)const{ return val>rhs.val; } constexpr bool operator<=(mod_int const& rhs)const{ return !(val>rhs.val); } constexpr bool operator>=(mod_int const& rhs)const{ return !(val>(std::istream& is, mod_int & mi){ int64_t t=0;is>>t; mi = mod_int(t); return is; } constexpr mod_int inverse(){ int64_t a=val,b=MOD,u=1,v=0,t=0; while(b>0){ t=a/b; std::swap(a-=t*b,b); std::swap(u-=t*v,v); } return mod_int(u); } constexpr mod_int mpow(int64_t n)const{ mod_int res(1),e(*this); while(n){ if(n&1)res*=e; e*=e; n>>=1; } return res; } }; using mint = mod_int<1000000007>; mint mpow(int64_t p,int64_t n){ mint res=1; mint e = p; while(n){ if(n&1)res*=e; e*=e; n>>=1; } return res; } template struct matrix{ int row,col; T add_identity,mul_identity; std::vector> data; constexpr matrix(){} constexpr matrix(int n,T ai,T mi):row(n),col(n),add_identity(ai),mul_identity(mi),data(n,std::vector(n,ai)){} constexpr matrix(int r,int c,T ai,T mi):row(r),col(c),add_identity(ai),mul_identity(mi),data(r,std::vector(c,ai)){} constexpr matrix(int r,int c,T v,T ai,T mi):row(r),col(c),add_identity(ai),mul_identity(mi),data(r,std::vector(c,v)){} std::vector& operator[](int r){return data[r];} constexpr const inline std::vector& operator[](int r)const{return data[r];} constexpr inline std::vector& at(int r){return data.at(r);} constexpr matrix identity_matrix()const{ assert(row==col); matrix ide(row,col,add_identity,add_identity,mul_identity); for(int i=0;i>(std::iostream& is,matrix& mat){ for(int i=0;i>mat.data[i][j]; return is; } constexpr matrix pow(int64_t n){ matrix a = *this; matrix res = identity_matrix(); while(n){ if(n&1)res=res*a; a=a*a; n>>=1; } return res; } }; signed main(){ using namespace std; matrix a(3,3,0,1); matrix b(3,1,0,1); a[0][0] = a[1][1] = a[2][2] = 1; a[0][1] = a[1][2] = a[2][0] = -1; int64_t n; cin>>n; a = a.pow(n-1); //cin>>b; cin>>b[0][0]>>b[1][0]>>b[2][0]; cout<< a*b <