#include <bits/stdc++.h>
using namespace std;
struct Matrix {
  long long data[2][2];
  long long &operator()(int x, int y) { return data[x][y]; }
};
Matrix Multiply(Matrix &a, Matrix &b) {
  Matrix c;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      c(i, j) = 0;
      for (int k = 0; k < 2; ++k) c(i, j) += a(i, k) * b(k, j);
      c(i, j) %= 1000000007;
    }
  }
  return c;
}
Matrix Power(Matrix &a, long long n) {
  Matrix p = a;
  Matrix product;
  product(0, 0) = 1;
  product(0, 1) = 0;
  product(1, 0) = 0;
  product(1, 1) = 1;
  for (int i = 0; i < 62; ++i) {
    if (n & (1LL << i)) product = Multiply(p, product);
    p = Multiply(p, p);
  }
  return product;
}
int main(int argc, char *argv[]) {
  Matrix a;
  a(0, 0) = 3;
  a(0, 1) = 1;
  a(1, 0) = 1;
  a(1, 1) = 3;
  long long n;
  cin >> n;
  Matrix r = Power(a, n);
  cout << r(0, 0) << endl;
  return 0;
}
