#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;
template <typename T>
struct Matrix {
  vector<vector<T> > data;
  int nrow, ncol;
  T MMOD;
  Matrix(int nrow_, int ncol_, T MMOD_ = -1)
      : nrow(nrow_), ncol(ncol_), MMOD(MMOD_) {
    data.clear();
    data.resize(nrow, vector<T>(0, 0));
    for (int i = 0; i < nrow; ++i) data[i].resize(ncol, 0);
  }
  Matrix(int nrow_, int ncol_, vector<vector<T> > data_, T MMOD_ = -1)
      : nrow(nrow_), ncol(ncol_), data(data_), MMOD(MMOD_) {}
  Matrix operator*(Matrix b) const {
    if (ncol != b.nrow) {
      cout << "multiplication error: matrices' size not valid \n";
      return Matrix(0, 0, MMOD);
    }
    Matrix<T> res(nrow, b.ncol, MMOD);
    for (int i = 0; i < nrow; ++i)
      for (int j = 0; j < b.ncol; ++j)
        for (int k = 0; k < ncol; ++k) {
          res.data[i][j] += data[i][k] * b.data[k][j];
          if (MMOD > 0 && res.data[i][j] > MMOD) res.data[i][j] %= MMOD;
        }
    return res;
  }
  Matrix pow(long long exp) {
    if (ncol != nrow) {
      cout << "Power error: matrices' size not valid \n";
      return Matrix(0, 0, MMOD);
    }
    if (exp == 0) return Matrix(nrow, ncol, MMOD);
    if (exp == 1) return Matrix<T>(nrow, ncol, data, MMOD);
    Matrix res = pow(exp >> 1);
    res = res * res;
    if (exp & 1) res = res * (*this);
    return res;
  }
  void print() {
    cout << "print matrix " << nrow << " x " << ncol << endl;
    for (int i = 0; i < nrow; ++i) {
      for (int j = 0; j < ncol; ++j) cout << data[i][j] << " ";
      cout << "\n";
    }
  }
};
long long n;
bool input() {
  cin >> n;
  return !cin.fail();
}
void process() {
  if (n == 0) {
    cout << 1 << endl;
    return;
  }
  Matrix<long long> fMatrix(2, 1, MOD);
  fMatrix.data[0][0] = 1;
  fMatrix.data[1][0] = 0;
  Matrix<long long> baseMatrix(2, 2, MOD);
  baseMatrix.data[0][0] = 3;
  baseMatrix.data[0][1] = 1;
  baseMatrix.data[1][0] = 1;
  baseMatrix.data[1][1] = 3;
  Matrix<long long> multiplied = baseMatrix.pow(n);
  Matrix<long long> mat_res = multiplied * fMatrix;
  cout << mat_res.data[0][0] << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while (input()) {
    process();
  }
  return 0;
}
