#include <bits/stdc++.h>
using namespace std;
long long int M = 1000000007;
long long int Fp(long long int N, long long int P) {
  if (P == 0) return 1;
  if (P % 2 == 0) {
    long long int ret = Fp(N, P / 2);
    return (ret * ret) % M;
  } else
    return (N * Fp(N, P - 1)) % M;
}
int main() {
  long long int n, u, d, f;
  cin >> n;
  if (n == 0)
    cout << 1 << endl;
  else if (n == 1)
    cout << 3 << endl;
  else {
    u = Fp(2, n - 1);
    d = (Fp(2, n) + 1) % M;
    f = (u * d) % M;
    cout << f << endl;
  }
}
