#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
typedef long long LL;
const int maxn=1e5 +5 ;
const int mod=1e9 +7 ;
LL n;
struct Matrix
{
LL mat[4 ][4 ];
Matrix()
{
memset (mat,0 ,sizeof (mat));
}
Matrix operator -(Matrix &tmp)
{
Matrix res;
for (int i=0 ; i<4 ; i++)
for (int j=0 ; j<4 ; j++)
{
res.mat[i][j]=mat[i][j]-tmp.mat[i][j]+mod;
res.mat[i][j]%=mod;
}
return res;
}
Matrix operator *(Matrix &tmp)
{
Matrix res;
memset (res.mat,0 ,sizeof (res.mat));
for (int i=0 ; i<4 ; ++i)
for (int j=0 ; j<4 ; ++j)
for (int k=0 ; k<4 ; ++k)
{
res.mat[i][j]+=mat[i][k]*tmp.mat[k][j];
res.mat[i][j]%=mod;
}
return res;
}
};
Matrix pow_M(Matrix a,LL n)
{
Matrix ret;
memset (ret.mat,0 ,sizeof (ret.mat));
ret.mat[0 ][0 ]=ret.mat[1 ][1 ]=1 ;
Matrix temp=a;
while (n)
{
if (n&1 )ret=ret*temp;
temp=temp*temp;
n>>=1 ;
}
return ret;
}
LL pow_m(LL a,LL n)
{
LL ret=1 ;
LL temp=a%mod;
while (n)
{
if (n&1 )
{
ret*=temp;
ret%=mod;
}
temp*=temp;
temp%=mod;
n>>=1 ;
}
return ret;
}
int main()
{
while (~scanf ("%I64d" ,&n))
{
Matrix A,B,C;
A.mat[0 ][0 ]=1 ;
A.mat[0 ][1 ]=5 ;
A.mat[0 ][2 ]=1 ;
A.mat[0 ][3 ]=-1 ;
A.mat[1 ][0 ]=1 ;
A.mat[2 ][1 ]=1 ;
A.mat[3 ][2 ]=1 ;
B.mat[0 ][0 ]=36 ;
B.mat[1 ][0 ]=11 ;
B.mat[2 ][0 ]=5 ;
B.mat[3 ][0 ]=1 ;
if (n==1 )
{
printf ("1\n" );
continue ;
}
if (n==2 )
{
printf ("5\n" );
continue ;
}
if (n==3 )
{
printf ("11\n" );
continue ;
}
if (n==4 )
{
printf ("36\n" );
continue ;
}
C=pow_M(A,n-4 )*B;
printf ("%I64d\n" ,(C.mat[0 ][0 ]+mod)%mod);
}
return 0 ;
}
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
typedef long long LL;
const int maxn=1e5 +5 ;
const int mod=1e9 +7 ;
LL n;
struct Matrix
{
LL mat[6 ][6 ];
Matrix(){memset (mat,0 ,sizeof (mat));}
Matrix operator -(Matrix &tmp)
{
Matrix res;
for (int i=0 ; i<6 ; i++)
for (int j=0 ; j<6 ; j++)
{
res.mat[i][j]=mat[i][j]-tmp.mat[i][j]+mod;
res.mat[i][j]%=mod;
}
return res;
}
Matrix operator *(Matrix &tmp)
{
Matrix res;
memset (res.mat,0 ,sizeof (res.mat));
for (int i=0 ; i<6 ; ++i)
for (int j=0 ; j<6 ; ++j)
for (int k=0 ; k<6 ; ++k)
{
res.mat[i][j]+=mat[i][k]*tmp.mat[k][j];
res.mat[i][j]%=mod;
}
return res;
}
};
Matrix pow_M(Matrix a,LL n)
{
Matrix ret;
memset (ret.mat,0 ,sizeof (ret.mat));
ret.mat[0 ][0 ]=ret.mat[1 ][1 ]=1 ;
Matrix temp=a;
while (n)
{
if (n&1 )ret=ret*temp;
temp=temp*temp;
n>>=1 ;
}
return ret;
}
int main()
{
while (~scanf ("%I64d" ,&n))
{
Matrix A,B;
A.mat[0 ][0 ]=1 ;
A.mat[0 ][1 ]=1 ;
A.mat[0 ][3 ]=1 ;
A.mat[0 ][4 ]=1 ;
A.mat[0 ][5 ]=1 ;
A.mat[1 ][0 ]=1 ;
A.mat[1 ][4 ]=1 ;
A.mat[2 ][3 ]=1 ;
A.mat[3 ][0 ]=1 ;
A.mat[3 ][2 ]=1 ;
A.mat[4 ][0 ]=1 ;
A.mat[4 ][1 ]=1 ;
A.mat[5 ][0 ]=1 ;
B=pow_M(A,n);
printf ("%I64d\n" ,(B.mat[0 ][0 ])%mod);
}
return 0 ;
}