#include <bits/stdc++.h>
using namespace std;
struct Matrix {
  long long m[2][2];
};
long long i, j, k;
Matrix Mul(Matrix a, Matrix b) {
  Matrix c;
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      c.m[i][j] = 0;
      for (k = 0; k < 2; k++) {
        c.m[i][j] = (c.m[i][j] + a.m[i][k] * b.m[k][j]) % 1000000007;
      }
    }
  }
  return c;
}
int main() {
  long long n;
  Matrix a, b;
  scanf("%lld", &n);
  a.m[0][0] = 3;
  a.m[1][0] = 1;
  a.m[0][1] = 1;
  a.m[1][1] = 3;
  b.m[0][0] = 1;
  b.m[1][0] = 0;
  while (n) {
    if (n & 1) b = Mul(a, b);
    a = Mul(a, a);
    n >>= 1;
  }
  printf("%lld\n", b.m[0][0]);
  return 0;
}
