#include <bits/stdc++.h>
using namespace std;
FILE *in;
FILE *out;
long long fastPow(long long num, long long pwr) {
  long long ret = 1;
  while (pwr) {
    if (pwr & 1) ret = (ret * num) % 1000000007;
    num = (num * num) % 1000000007;
    pwr >>= 1;
  }
  return ret;
}
long long eval(long long n) {
  if (n == 0) return 1;
  if (n == 1) return 3;
  if (n == 2) return 10;
  return (fastPow(2, n * 2 - 1) + fastPow(2, n - 1)) % 1000000007;
}
long long recurse(long long rem, int up) {
  if (rem == 0) return up;
  return (recurse(rem - 1, up) * 3 + recurse(rem - 1, !up)) % 1000000007;
}
int main(void) {
  in = stdin;
  out = stdout;
  char buff[32];
  fscanf(in, "%s", buff);
  long long n = 0;
  for (int i = 0; i < (int)strlen(buff); i++) n = n * 10 + buff[i] - 48;
  fprintf(out, "%d\n", (int)eval(n));
  return 0;
}
