#include <bits/stdc++.h>
using namespace std;
const int maxn = 3, cnt = 2;
long long p = 1e9 + 7;
struct Matrix {
  long long a[maxn][maxn];
  void init() {
    memset(a, 0, sizeof(a));
    for (int i = 0; i < cnt; i++) a[i][i] = 1;
  }
  void clear() { memset(a, 0, sizeof(a)); }
  void bug() {
    for (int i = 0; i < cnt; i++) {
      for (int j = 0; j < cnt; j++) {
        printf("%5lld ", a[i][j]);
      }
      printf("\n");
    }
    printf("\n");
  }
  Matrix operator*(const Matrix& x) const {
    Matrix ans;
    ans.clear();
    for (int i = 0; i < cnt; i++)
      for (int j = 0; j < cnt; j++)
        for (int k = 0; k < cnt; k++) {
          ans.a[i][j] += a[i][k] * x.a[k][j];
          ans.a[i][j] %= p;
        }
    return ans;
  }
  Matrix operator+(const Matrix& x) const {
    Matrix ans;
    ans.clear();
    for (int i = 0; i < cnt; i++) {
      for (int j = 0; j < cnt; j++) {
        ans.a[i][j] = x.a[i][j] + a[i][j];
        ans.a[i][j] %= p;
      }
    }
    return ans;
  }
  Matrix operator^(long long b) const {
    Matrix ans, x = *this;
    ans.init();
    while (b) {
      if (b & 1) ans = ans * x;
      b >>= 1;
      x = x * x;
    }
    return ans;
  }
};
int main() {
  Matrix ans, bns;
  ans.clear();
  bns.clear();
  ans.a[0][0] = 3;
  ans.a[0][1] = 1;
  ans.a[1][0] = 1;
  ans.a[1][1] = 3;
  bns.a[0][0] = 1;
  bns.a[1][0] = 0;
  long long n;
  while (scanf("%lld", &n) == 1) {
    printf("%lld\n", ((ans ^ (n)) * bns).a[0][0]);
  }
  return 0;
}
