#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; const ll MOD = 1000000007LL; typedef vector vec; typedef vector mat; mat mul(mat &A, mat &B){ mat C(A.size(), vec(B[0].size())); rep(i,A.size()) rep(k,B.size()){ rep(j,B[0].size()){ C[i][j] = (C[i][j]+A[i][k]*B[k][j])%MOD; } } return C; } mat pow(mat A, ll n){ mat B(A.size(), vec(A.size())); rep(i,A.size()) B[i][i] = 1; while(n>0){ if(n&1) B=mul(B,A); A=mul(A,A); n>>=1; } return B; } int main(){ ll N; cin >> N; mat A = {{10,3},{0,1}}; mat x = {{1,0},{1,0}}; mat p = pow(A, N); mat ret = mul(p,x); cout << ret[0][0] << endl; return 0; }