#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll po(ll a,ll n){
ll res=a,ans=1;
while(n){
if(n%2) ans=ans*res%mod;
res=res*res%mod;
n/=2;
}
return ans;
}
int main(){
ll mod_4 = po(4,mod-2);
ll n;
cin>>n;
ll k;
if(n%2==0) {k =n/2;
ll res = 9*mod_4;
ll tmp = (po(9,k-1)-1+mod)%mod;
res = res*tmp%mod;
res=(res+3)%mod;
cout<<res;
return 0;
}
else {
k=(n-1)/2;
ll res = mod_4*3;
ll tmp = (po(9,k)-1+mod)%mod;
res = res*tmp%mod;
cout<<res;
return 0;
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcgCiNkZWZpbmUgbW9kIDEwMDAwMDAwMDcKbGwgcG8obGwgYSxsbCBuKXsKICAgICAgICBsbCByZXM9YSxhbnM9MTsKICAgICAgICB3aGlsZShuKXsKICAgICAgICAgICAgICAgIGlmKG4lMikgYW5zPWFucypyZXMlbW9kOwogICAgICAgICAgICAgICAgcmVzPXJlcypyZXMlbW9kOwogICAgICAgICAgICAgICAgbi89MjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGFuczsKfQppbnQgbWFpbigpewogICAgICAgIGxsIG1vZF80ID0gcG8oNCxtb2QtMik7CiAgICAgICAgbGwgbjsKICAgICAgICBjaW4+Pm47CiAgICAgICAgbGwgazsKICAgICAgICBpZihuJTI9PTApIHtrID1uLzI7CiAgICAgICAgICAgICAgICBsbCByZXMgPSA5Km1vZF80OwogICAgICAgICAgICAgICAgbGwgdG1wID0gKHBvKDksay0xKS0xK21vZCklbW9kOwogICAgICAgICAgICAgICAgcmVzID0gcmVzKnRtcCVtb2Q7CiAgICAgICAgICAgICAgICByZXM9KHJlcyszKSVtb2Q7CiAgICAgICAgICAgICAgICBjb3V0PDxyZXM7CiAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICB9CiAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICBrPShuLTEpLzI7CiAgICAgICAgICAgICAgICBsbCByZXMgPSBtb2RfNCozOwogICAgICAgICAgICAgICAgbGwgdG1wID0gKHBvKDksayktMSttb2QpJW1vZDsKICAgICAgICAgICAgICAgIHJlcyA9IHJlcyp0bXAlbW9kOwogICAgICAgICAgICAgICAgY291dDw8cmVzOwogICAgICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQp9