#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long a[15][15];
} e, f;
long long n, a, b, p = 1e9 + 7, ans;
edge cheng(edge a, edge b) {
  edge c;
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j <= 1; j++) c.a[i][j] = 0;
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j <= 1; j++)
      for (int k = 0; k <= 1; k++)
        c.a[i][j] = (c.a[i][j] + a.a[i][k] * b.a[k][j]) % p;
  return c;
}
edge jzksm(edge s, long long x) {
  if (x == 1) return e;
  edge s1 = jzksm(s, x / 2);
  if (x % 2 == 0) return cheng(s1, s1);
  return cheng(cheng(s1, s1), s);
}
int main() {
  e.a[0][0] = 3;
  e.a[0][1] = 1;
  e.a[1][0] = 1;
  e.a[1][1] = 3;
  while (scanf("%lld%", &n) != EOF) {
    if (n == 0) {
      printf("1\n");
      continue;
    }
    if (n == 1) {
      printf("3\n");
      continue;
    }
    f = jzksm(e, n - 1);
    ans = (3 * f.a[0][0] + f.a[0][1]) % p;
    printf("%lld\n", ans);
  }
  return 0;
}
