#include <bits/stdc++.h>
const int mod = (int)1e9 + 7;
struct Vector {
  long long a, b;
};
struct Matrix {
  long long a, b, c, d;
  Matrix mult(Matrix& m) {
    return Matrix{(a * m.a + b * m.c) % mod, (a * m.b + b * m.d) % mod,
                  (c * m.a + d * m.c) % mod, (c * m.b + d * m.d) % mod};
  }
  Vector mult(Vector& v) {
    return Vector{(a * v.a + b * v.b) % mod, (c * v.a + d * v.b) % mod};
  }
};
Matrix pow(Matrix a, long long n) {
  Matrix res{1, 0, 0, 1};
  while (n > 0) {
    if (n & 1) {
      res = res.mult(a);
    }
    a = a.mult(a);
    n /= 2;
  }
  return res;
}
int main() {
  long long n;
  std::cin >> n;
  Matrix A{3, 1, 1, 3};
  Vector x{1, 0};
  x = pow(A, n).mult(x);
  std::cout << x.a;
  return 0;
}
