n=int(input())
t=1000000007
n=pow(2,n,t)
n=n*(n+1)
n=n//2
print(n%t)
//multiplication of two matrix in O(n3);
#include<bits/stdc++.h>
using namespace std;
int MOD= 1000000007;
vector<vector<long long>> multiply(vector<vector<long long>> v1, vector<vector<long long>> & v2){
vector<vector<long long>> ans(v1.size(),vector<long long>(v1.size(), 0));
for(long long i=0;i<v1.size();i++){
for(long long j=0;j<v2.size();j++){
long long sum=0;
for(long long k=0;k<v2.size();k++){
sum+= (v1[i][k]*v2[k][j])%MOD;
sum = sum%MOD;
}
ans[i][j]= sum;
}
}
return ans;
}
vector<vector<long long>> matrixExpo(vector<vector<long long>> &a, long long n){
if(n==0){
vector<vector<long long>> ans(a.size(), vector<long long>(a.size(), 0));
for(long long i=0;i<a.size();i++){
ans[i][i]=1;
}
return ans;
}
if(n==1){
return a;
}
vector<vector<long long>> temp = matrixExpo(a, n/2);
vector<vector<long long>> ans = multiply(temp, temp);
if(n%2!=0){
ans = multiply(ans, a);
}
return ans;
}
void solve(){
long long n; cin>>n;
if(n==0){
cout<<1;
return;
}
n--;
vector<vector<long long>> a= {{6, -8}, {1, 0}};
vector<vector<long long>> ans = matrixExpo(a, n);
long long val = ((ans[0][0]*3)%MOD +(ans[0][1])%MOD)%MOD;
if(val<0){
val = val+MOD;
}
cout<<val;
}
int main()
{
long long t=1;
for(long long it=1;it<=t;it++) {
solve();
}
return 0;
}
1663D - Is it rated - 3 | 1311A - Add Odd or Subtract Even |
977F - Consecutive Subsequence | 939A - Love Triangle |
755A - PolandBall and Hypothesis | 760B - Frodo and pillows |
1006A - Adjacent Replacements | 1195C - Basketball Exercise |
1206A - Choose Two Numbers | 1438B - Valerii Against Everyone |
822A - I'm bored with life | 9A - Die Roll |
1430B - Barrels | 279B - Books |
1374B - Multiply by 2 divide by 6 | 1093B - Letters Rearranging |
1213C - Book Reading | 1468C - Berpizza |
1546B - AquaMoon and Stolen String | 1353C - Board Moves |
902A - Visiting a Friend | 299B - Ksusha the Squirrel |
1647D - Madoka and the Best School in Russia | 1208A - XORinacci |
1539B - Love Song | 22B - Bargaining Table |
1490B - Balanced Remainders | 264A - Escape from Stones |
1506A - Strange Table | 456A - Laptops |