#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
typedef int mat[2][2];
void unitmat(mat a) { a[0][0] = a[1][1] = 1, a[0][1] = a[1][0] = 0; }
void copymat(const mat a, mat b) { memcpy(b, a, sizeof(mat)); }
void mulmat(const mat a, const mat b, mat c) {
  c[0][0] = ((long long)a[0][0] * b[0][0] % MOD +
             (long long)a[0][1] * b[1][0] % MOD) %
            MOD;
  c[0][1] = ((long long)a[0][0] * b[0][1] % MOD +
             (long long)a[0][1] * b[1][1] % MOD) %
            MOD;
  c[1][0] = ((long long)a[1][0] * b[0][0] % MOD +
             (long long)a[1][1] * b[1][0] % MOD) %
            MOD;
  c[1][1] = ((long long)a[1][0] * b[0][1] % MOD +
             (long long)a[1][1] * b[1][1] % MOD) %
            MOD;
}
void powmat(const mat a, long long b, mat c) {
  mat s, t;
  unitmat(c);
  copymat(a, s);
  while (b > 0) {
    if ((b & 1) != 0) mulmat(c, s, t), copymat(t, c);
    mulmat(s, s, t), copymat(t, s);
    b >>= 1;
  }
}
int main() {
  long long n;
  scanf("%lld", &n);
  mat ma, mc;
  ma[0][0] = 3, ma[0][1] = 1;
  ma[1][0] = 1, ma[1][1] = 3;
  powmat(ma, n, mc);
  printf("%d\n", mc[0][0]);
  return 0;
}
