#include <bits/stdc++.h>
using namespace std;
long long n, m = 1000000007;
long long ansMat[3], tempAns[3], mulMat[3][3], tempMul[3][3];
void store() {
  for (int i = 0; i < 2; i++) {
    long long temp = 0;
    for (int j = 0; j < 2; j++) {
      temp = (temp % m + (ansMat[j] % m * mulMat[j][i] % m)) % m;
    }
    tempAns[i] = temp % m;
  }
  for (int i = 0; i < 2; i++) {
    ansMat[i] = tempAns[i];
  }
}
void multiply() {
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      long long temp = 0;
      for (int k = 0; k < 2; k++) {
        temp = (temp % m + (mulMat[i][k] % m * mulMat[k][j]) % m) % m;
      }
      tempMul[i][j] = temp;
    }
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      mulMat[i][j] = tempMul[i][j] % m;
    }
  }
}
int main() {
  long long n;
  scanf("%lld", &n);
  ansMat[0] = 1;
  ansMat[1] = 0;
  mulMat[0][0] = 3;
  mulMat[0][1] = 1;
  mulMat[1][0] = 1;
  mulMat[1][1] = 3;
  while (n) {
    if (n & 1) {
      store();
    }
    multiply();
    n = n >> 1;
  }
  printf("%lld\n", ansMat[0]);
}
