#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long expo(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * (a % mod)) % mod;
    a = (a % mod) * (a % mod) % mod;
    b >>= 1;
  }
  return ans;
}
int main() {
  long long n;
  cin >> n;
  if (n == 0)
    cout << 1 << "\n";
  else {
    long long a, b, c;
    a = 3LL * expo(2LL, n - 1LL, mod), b = expo(2LL, 2LL * n - 1LL, mod),
    c = expo(2LL, n, mod);
    long long ans = (((a % mod + b % mod) % mod - c % mod + mod) % mod) % mod;
    cout << ans << "\n";
  }
}
