#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long n;
struct Mar {
  long long arr[5][5];
} E, st;
void init() {
  memset(E.arr, 0, sizeof(E.arr));
  memset(st.arr, 0, sizeof(st.arr));
  E.arr[1][1] = E.arr[2][2] = 1;
  st.arr[1][1] = 3, st.arr[1][2] = 1;
  st.arr[2][1] = 1, st.arr[2][2] = 3;
}
void output(Mar c) {
  for (int i = 1; i <= 2; i++) {
    for (int j = 1; j <= 2; j++) {
      printf("%d ", c.arr[i][j]);
    }
    printf("\n");
  }
}
Mar mul(Mar a, Mar b, long long k, int flag) {
  Mar c;
  for (int i = 1; i <= 2; i++) {
    for (int j = 1; j <= 2; j++) {
      c.arr[i][j] = 0;
      for (int k = 1; k <= 2; k++) {
        c.arr[i][j] += ((a.arr[i][k] % mod) * (b.arr[k][j] % mod)) % mod;
        c.arr[i][j] = c.arr[i][j] % mod;
      }
    }
  }
  return c;
}
Mar pow(Mar base, long long k) {
  Mar ans = E;
  while (k) {
    if (k & 1) ans = mul(ans, base, k, 1);
    base = mul(base, base, k, 2);
    k >>= 1;
  }
  return ans;
}
int main() {
  scanf("%lld", &n);
  if (n == 0) {
    printf("1\n");
    return 0;
  }
  init();
  Mar ans = pow(st, n);
  printf("%lld\n", (ans.arr[1][1] + mod) % mod);
  return 0;
}
