#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1073741824")
const int INF = 1000000000;
using namespace std;
void prepare(string s) {}
long long n;
int mod = 1000000007;
long long ans;
void readdata() { cin >> n; }
void writedata() { cout << ans << endl; }
int pow(long long n) {
  if (n == 1) return 2;
  if (n == 0) return 1;
  if (n & 1) {
    long long k = pow(n >> 1);
    return (((k * k) % mod) * 2) % mod;
  } else {
    long long k = pow(n >> 1);
    return (k * k) % mod;
  }
}
void solve() {
  if (n < 3) {
    if (n == 0) ans = 1;
    if (n == 1) ans = 3;
    if (n == 2) ans = 10;
    return;
  }
  ans = pow(n);
  ans = (ans * ((ans + 1) % mod)) % mod;
  ans = (ans * pow(1000000007 - 2)) % mod;
}
int main() {
  prepare("divgold");
  readdata();
  solve();
  writedata();
  return 0;
}
