#include <bits/stdc++.h>
using namespace std;
long long n, ans, tmp, mo, f[2][2];
void mul(long long a[][2], long long b[][2]) {
  long long i, j, s, k, c[2][2];
  for (i = 0; i < 2; i++)
    for (j = 0; j < 2; j++) {
      s = 0;
      for (k = 0; k < 2; k++) s = (s + a[i][k] * b[k][j]) % mo;
      c[i][j] = s;
    }
  for (i = 0; i < 2; i++)
    for (j = 0; j < 2; j++) a[i][j] = c[i][j];
}
long long solve(long long n) {
  int i, j;
  long long ans[2][1], s0, s1;
  ans[0][0] = 0;
  ans[1][0] = 1;
  while (n > 0) {
    if (n & 1 == 1) {
      s0 = f[0][0] * ans[0][0] + f[0][1] * ans[1][0];
      s1 = f[1][0] * ans[0][0] + f[1][1] * ans[1][0];
      ans[0][0] = s0 % mo;
      ans[1][0] = s1 % mo;
    }
    mul(f, f);
    n = n >> 1;
  }
  return ans[1][0];
}
int main() {
  mo = 1000000007;
  scanf("%I64d", &n);
  f[0][0] = f[1][1] = 3;
  f[0][1] = f[1][0] = 1;
  if (n == 0) {
    printf("1\n");
    return 0;
  }
  ans = solve(n);
  printf("%I64d\n", ans);
}
