#include <bits/stdc++.h>
using namespace std;
void mul(unsigned long long int F[2][2], unsigned long long int M[2][2]) {
  unsigned long long int x =
      F[0][0] * M[0][0] % 1000000007 + F[0][1] * M[1][0] % 1000000007;
  unsigned long long int y =
      F[0][0] * M[0][1] % 1000000007 + F[0][1] * M[1][1] % 1000000007;
  unsigned long long int z =
      F[1][0] * M[0][0] % 1000000007 + F[1][1] * M[1][0] % 1000000007;
  unsigned long long int o =
      F[1][0] * M[0][1] % 1000000007 + F[1][1] * M[1][1] % 1000000007;
  F[0][0] = x % 1000000007;
  F[0][1] = y % 1000000007;
  F[1][0] = z % 1000000007;
  F[1][1] = o % 1000000007;
}
void power(unsigned long long int F[2][2], unsigned long long int n) {
  if (n == 0 || n == 1) return;
  unsigned long long int N[2][2] = {{3, 1}, {1, 3}};
  power(F, n / 2);
  mul(F, F);
  if (n % 2 != 0) mul(F, N);
}
int main() {
  unsigned long long int n, F[2][2] = {{3, 1}, {1, 3}};
  cin >> n;
  if (n == 0)
    cout << "1" << endl;
  else {
    power(F, n);
    cout << F[0][0] % 1000000007 << endl;
  }
  return 0;
}
