#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
struct Matrix {
  long long num[2][2];
  Matrix(bool flag) {
    if (!flag) {
      memset(num, 0, sizeof(num));
    } else {
      num[0][0] = 3;
      num[0][1] = 1;
      num[1][0] = 1;
      num[1][1] = 3;
    }
  }
  Matrix operator*(const Matrix &p) const {
    Matrix res = Matrix(false);
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          res.num[i][j] = (res.num[i][j] + num[i][k] * p.num[k][j] % mod) % mod;
        }
      }
    return res;
  }
};
Matrix ff(long long time) {
  Matrix res = Matrix(false);
  Matrix p = Matrix(true);
  res.num[0][0] = res.num[1][1] = 1;
  res.num[0][1] = res.num[1][0] = 0;
  while (time) {
    if (time & 1) res = p * res;
    p = p * p;
    time >>= 1;
  }
  return res;
}
int main() {
  long long n;
  while (scanf("%I64d", &n) == 1) {
    Matrix ans = ff(n);
    cout << ans.num[0][0] << endl;
  }
  return 0;
}
