#include <bits/stdc++.h>
using namespace std;
long long n;
vector<vector<long long> > T(3, vector<long long>(3)), ans;
vector<vector<long long> > mult(vector<vector<long long> > a,
                                vector<vector<long long> > b) {
  vector<vector<long long> > c(3, vector<long long>(3));
  for (int i = 0; i < (int)3; i++)
    for (int j = 0; j < (int)3; j++) c[i][j] = 0;
  for (int i = 0; i < (int)3; i++)
    for (int j = 0; j < (int)3; j++)
      for (int k = 0; k < (int)3; k++)
        c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % 1000000007;
  return c;
}
vector<vector<long long> > exp(vector<vector<long long> > M, long long e) {
  if (e == 1) return M;
  if (e % 2 != 0) return mult(M, exp(M, e - 1));
  vector<vector<long long> > X = exp(M, e / 2);
  return mult(X, X);
}
int main() {
  scanf("%I64d", &n);
  if (n == 0) {
    printf("1");
    exit(0);
  }
  T[0][0] = 3, T[0][1] = 1;
  T[1][0] = 1, T[1][1] = 3;
  ans = exp(T, n);
  printf("%I64d", ans[0][0]);
}
