#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007, unit[2][2] = {{1, 0}, {0, 1}},
                base[2][2] = {{3, 1}, {1, 3}};
long long temp[2][2], power[2][2];
int i, j, k;
bool flag;
inline void mult() {
  if (flag)
    for (i = 0; i < 2; ++i)
      for (j = 0; j < 2; ++j) {
        temp[i][j] = 0;
        for (k = 0; k < 2; ++k) {
          temp[i][j] += (power[i][k] * power[k][j]) % mod;
          temp[i][j] %= mod;
        }
      }
  else
    for (i = 0; i < 2; ++i)
      for (j = 0; j < 2; ++j) {
        temp[i][j] = 0;
        for (k = 0; k < 2; ++k) {
          temp[i][j] += (base[i][k] * power[k][j]) % mod;
          temp[i][j] %= mod;
        }
      }
  memcpy(power, temp, sizeof(temp));
}
inline void pow(long long n) {
  if (n == 0) {
    memcpy(power, unit, sizeof(unit));
    return;
  }
  pow(n >> 1);
  flag = true;
  mult();
  if (n & 1) {
    flag = false;
    mult();
  }
}
int main(void) {
  long long n;
  scanf("%I64d", &n);
  if (n == 0)
    puts("1\n");
  else {
    pow(n);
    printf("%I64d\n", power[1][1]);
  }
  return 0;
}
