#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
struct mat {
  long long aa[2][2];
  mat() { memset(aa, 0, sizeof(aa)); }
};
mat ans, cnt;
mat mmul(mat &a, mat &b) {
  mat c;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      c.aa[i][j] = 0;
      for (int k = 0; k < 2; k++) {
        c.aa[i][j] += (a.aa[i][k] * b.aa[k][j]) % mod;
        c.aa[i][j] %= mod;
      }
    }
  }
  return c;
}
mat mpow(mat a, long long n) {
  mat b;
  b.aa[0][0] = b.aa[1][1] = 1;
  while (n) {
    if (n & 1) b = mmul(b, a);
    a = mmul(a, a);
    n >>= 1;
  }
  return b;
}
int main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  ans.aa[0][0] = 3;
  ans.aa[0][1] = 1;
  ans.aa[1][0] = 1;
  ans.aa[1][1] = 3;
  cnt.aa[0][0] = 1;
  cnt.aa[1][0] = 0;
  mat _;
  ans = mpow(ans, n);
  _ = mmul(ans, cnt);
  cout << _.aa[0][0] % mod << endl;
  return 0;
}
