#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <typename T>
class Matrix {
 public:
  vector<vector<T> > A;
  int r, c;
  Matrix(int r, int c) {
    this->r = r;
    this->c = c;
    A.assign(r, vector<T>(c));
  }
  Matrix(int r, int c, T val) {
    this->r = r;
    this->c = c;
    A.assign(r, vector<T>(c, val));
  }
  Matrix(int n) {
    this->r = this->c = n;
    A.assign(n, vector<T>(n));
    for (int i = 0; i < n; i++) A[i][i] = (T)1;
  }
  void display() {
    for (int i = 0; i < r; i++) {
      for (int j = 0; j < c; j++) cout << A[i][j] << " ";
      cout << endl;
    }
  }
  void input() {}
  Matrix operator*(Matrix &B) {
    assert(c == B.r);
    int i, j, k;
    int x = r;
    int y = c;
    int z = B.c;
    Matrix<T> C(x, z, 0);
    for (i = 0; i < x; i++)
      for (j = 0; j < z; j++)
        for (k = 0; k < y; k++)
          C[i][j] = (C[i][j] + ((long long)A[i][k] * (long long)B[k][j])) % mod;
    return C;
  }
  Matrix operator+(Matrix &B) {
    assert(r == B.r);
    assert(c == B.c);
    Matrix<T> C(r, c, 0);
    int i, j;
    for (i = 0; i < r; i++)
      for (j = 0; j < c; j++) C[i][j] = (A[i][j] + B[i][j]) % mod;
    return C;
  }
  Matrix operator-() {
    Matrix<T> C(r, c, 0);
    int i, j;
    for (i = 0; i < r; i++)
      for (j = 0; j < c; j++) C[i][j] = -A[i][j];
    return C;
  }
  Matrix operator-(Matrix &B) {
    assert(r == B.r);
    assert(c == B.c);
    Matrix<T> C(r, c, 0);
    int i, j;
    for (i = 0; i < r; i++)
      for (j = 0; j < c; j++) {
        C[i][j] = (A[i][j] - B[i][j]) % mod;
        if (C[i][j] < 0) C[i][j] += mod;
      }
    return C;
  }
  Matrix operator^(long long n) {
    assert(r == c);
    int i, j;
    Matrix C(r);
    Matrix X(r, c, 0);
    for (i = 0; i < r; i++)
      for (j = 0; j < c; j++) X[i][j] = A[i][j];
    while (n) {
      if (n & 1) C = C * X;
      X = X * X;
      n /= 2;
    }
    return C;
  }
  vector<T> &operator[](int i) {
    assert(i < r);
    assert(i >= 0);
    return A[i];
  }
  friend ostream &operator<<(ostream &out, Matrix &M) {
    for (int i = 0; i < M.r; ++i) {
      for (int j = 0; j < M.c; ++j) {
        out << M[i][j] << " ";
      }
      out << '\n';
    }
    return out;
  }
};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  long long n;
  cin >> n;
  Matrix<long long> mat(2, 2);
  mat[0][0] = 6, mat[0][1] = -8 + mod, mat[1][0] = 1, mat[1][1] = 0;
  mat = mat ^ n;
  long long ret = mat[1][0] * 3 + mat[1][1] * 1;
  ret %= mod;
  cout << ret;
  return 0;
}
