#include<iostream>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int qk(ll a, ll b)
{
ll ans=1;
a=a%mod;
while(b)
{
if(b%2==1)
ans=(ans*a)%mod;
b=b/2;
a=(a*a)%mod;
}
return ans;
}
int main(){
ll n;
while(cin>>n)
{
ll c=qk(2,mod-2);
ll zi=qk(3,n+1)-1;
cout<<(zi%mod*c)%mod<<endl;
}
}