#include <bits/stdc++.h>
using namespace std;
const long long P = 1000000007;
struct Mat {
  long long d[2][2];
  Mat operator*(const Mat& mat) const {
    Mat ret;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) {
        ret.d[i][j] = 0;
        for (int k = 0; k < 2; k++)
          ret.d[i][j] = (ret.d[i][j] + d[i][k] * mat.d[k][j]) % P;
      }
    return ret;
  }
};
Mat pow(Mat a, long long n) {
  Mat ret;
  ret.d[0][0] = ret.d[1][1] = 1;
  ret.d[0][1] = ret.d[1][0] = 0;
  while (n) {
    if (n & 1) ret = ret * a;
    a = a * a;
    n >>= 1;
  }
  return ret;
}
int main() {
  long long N;
  Mat M, ret;
  M.d[0][0] = M.d[1][1] = 3;
  M.d[0][1] = M.d[1][0] = 1;
  while (scanf("%I64d", &N) == 1) {
    ret = pow(M, N);
    printf("%I64d\n", ret.d[0][0]);
  }
  return 0;
}
