#include <bits/stdc++.h>
using namespace std;
const int N = 2;
const long long mod = 1e9 + 7;
struct matrix {
  long long mat[N][N];
  matrix operator*(matrix &other) {
    matrix ans;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        ans.mat[i][j] = 0LL;
        for (int k = 0; k < N; k++) {
          ans.mat[i][j] += this->mat[i][k] * other.mat[k][j];
          ans.mat[i][j] %= mod;
        }
      }
    }
    return ans;
  }
};
matrix ident, base, en;
matrix fast_pow(matrix &base, long long p) {
  if (p == 0LL) {
    return ident;
  }
  if (p == 1LL) {
    return base;
  }
  matrix r = fast_pow(base, p / 2LL);
  r = r * r;
  if (p & 1LL) {
    r = r * base;
  }
  return r;
}
int main() {
  long long n;
  ident.mat[0][0] = ident.mat[1][1] = 1LL;
  base.mat[0][0] = base.mat[1][1] = 3LL;
  base.mat[0][1] = base.mat[1][0] = 1LL;
  en.mat[0][0] = 1LL;
  scanf("%lld", &n);
  base = fast_pow(base, n);
  base = base * en;
  printf("%lld\n", base.mat[0][0]);
  return 0;
}
