#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
struct Matrix {
  long long c[3][3];
};
Matrix base, e;
Matrix mul(Matrix x, Matrix y) {
  Matrix z;
  memset(z.c, 0, sizeof(z.c));
  for (int i = 1; i <= 2; i++) {
    for (int j = 1; j <= 2; j++) {
      for (int k = 1; k <= 2; k++) {
        z.c[i][j] += x.c[i][k] * y.c[k][j];
        z.c[i][j] = z.c[i][j] % mod;
      }
    }
  }
  return z;
}
Matrix qpow(Matrix x, long long n) {
  if (n == 0) return e;
  if (n % 2 == 1) {
    return mul(qpow(x, n - 1), x);
  } else {
    Matrix temp = qpow(x, n / 2);
    return mul(temp, temp);
  }
}
int main() {
  long long x;
  base.c[1][1] = 3, base.c[1][2] = 1, base.c[2][1] = 1, base.c[2][2] = 3;
  e.c[1][1] = 1, e.c[1][2] = 0, e.c[2][1] = 0, e.c[2][2] = 1;
  cin >> x;
  Matrix ans = qpow(base, x);
  cout << ans.c[1][1] << endl;
  return 0;
}
