#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const long long mxn = 3e5 + 5;
struct matrix {
  vector<vector<long long>> a;
  long long sz;
  matrix(long long n) {
    sz = n;
    a.resize(n);
    for (long long i = 0; i < n; i++) a[i].resize(sz);
  }
  void set(long long x) {
    for (long long i = 0; i < sz; i++)
      for (long long j = 0; j < sz; j++) a[i][j] = x;
  }
  void print() {
    for (long long i = 0; i < sz; i++) {
      for (long long j = 0; j < sz; j++) cout << a[i][j] << " ";
      cout << '\n';
    }
  }
  void iden() {
    set(0);
    for (long long i = 0; i < sz; i++) a[i][i] = 1;
  }
  matrix operator*(const matrix& p) {
    matrix res(p.sz);
    for (long long i = 0; i < sz; i++) {
      for (long long j = 0; j < sz; j++) {
        for (long long k = 0; k < sz; k++) {
          res.a[i][j] += ((a[i][k] % mod) * (p.a[k][j] % mod)) % mod;
        }
      }
    }
    return res;
  }
};
matrix Matrixexpo(matrix a, long long y) {
  matrix res(a.sz);
  res.iden();
  while (y) {
    if (y & 1) res = res * a;
    a = a * a;
    y = y / 2;
  }
  return res;
}
long long solve() {
  long long n;
  cin >> n;
  matrix M(2);
  M.a[0][0] = 3;
  M.a[0][1] = 1;
  M.a[1][0] = 1;
  M.a[1][1] = 3;
  M = Matrixexpo(M, n);
  cout << M.a[0][0] % mod << '\n';
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(20);
  long long tests = 1;
  for (long long i = 1; i <= tests; i++) {
    solve();
  }
  return 0;
}
